jmeter-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 62426] New: Here are some Reduced ReportGenerator performance Code
Date Mon, 04 Jun 2018 05:58:10 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=62426

            Bug ID: 62426
           Summary: Here are some Reduced ReportGenerator performance Code
           Product: JMeter
           Version: 4.0
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Main
          Assignee: issues@jmeter.apache.org
          Reporter: 444104595@qq.com
  Target Milestone: ---

Importance from high to low:
1.
public class TransactionsPerSecondGraphConsumer extends
        AbstractOverTimeGraphConsumer
@Override
                    public Iterable<String> select(Sample sample) {
                        String label = String.format(STATUS_SERIES_FORMAT,
                                sample.getName(),
                                sample.getSuccess() ? SUCCESS_SERIES_SUFFIX
                                        : FAILURE_SERIES_SUFFIX);
                        return Arrays.asList(label);
                    }
String.format  can replace to "" + "";


2.
public class SyntheticResponseTimeDistributionGraphConsumer extends
        AbstractGraphConsumer {
                if(elapsedTime<=getSatisfiedThreshold()) {
                    return Arrays.asList(SATISFIED_LABEL.format(new Object[]
{Long.valueOf(getSatisfiedThreshold())}));
                } else if(elapsedTime <= getToleratedThreshold()) {
                    return Arrays.asList(TOLERATED_LABEL.format(new Object[]
{Long.valueOf(getSatisfiedThreshold()),
Long.valueOf(getToleratedThreshold())}));
                } else {
                    return Arrays.asList(UNTOLERATED_LABEL.format(new Object[]
{Long.valueOf(getToleratedThreshold())}));
                }
The same: String.format  to slow.

3.
public final class CSVSaveService {
    public static String[] csvReadFile(BufferedReader infile, char delim)
            throws IOException {
why not use like this:
        String str = infile.readLine();
        if (str == null) {
            return new String[]{};
        }
        return str.split("" + delim);
the code:
if ((ch == '\n' || ch == '\r') && state != ParserState.QUOTED) 
Consumes a lot of CPU time

4.
public class NormalizerSampleConsumer extends AbstractSampleConsumer {
public void consume(Sample s, int channel) {

I just return
super.produce(s, 0);

5.
public class SampleMetadata {
private TreeMap<String, Integer> index = new TreeMap<>();

why not use 
private HashMap<String, Integer> index = new HashMap<>();

6.
    public static <T> T convert(Class<T> clazz, String value)
            throws ConvertException {
why not just return like bellow:  

f (clazz.isAssignableFrom(String.class)) {
            return (T) value;
        }
        if (clazz.isAssignableFrom(Long.class) ||
clazz.isAssignableFrom(long.class)) {
            return (T) Long.valueOf(value);
        }
        if (clazz.isAssignableFrom(Boolean.class) ||
clazz.isAssignableFrom(boolean.class)) {
            return (T) Boolean.valueOf(value);
        }
        if (clazz.isAssignableFrom(Integer.class) ||
clazz.isAssignableFrom(int.class)) {
            return (T) Integer.valueOf(value);
        }
        if (clazz.isAssignableFrom(Double.class) ||
clazz.isAssignableFrom(double.class)) {
            return (T) Double.valueOf(value);
        }
        if (clazz.isAssignableFrom(Float.class) ||
clazz.isAssignableFrom(float.class)) {
            return (T) Float.valueOf(value);
        }
        if (clazz.isAssignableFrom(Character.class) ||
clazz.isAssignableFrom(char.class)) {
            return (T) Character.valueOf(value.charAt(0));
        }
        else {
            StringConverter<T> converter = Converters.getConverter(clazz);
            if (converter == null) {
                throw new ConvertException(value, clazz.getName());
            }
            result = converter.convert(value);
        }


My performance can be improved by at least 50%

The original code may be considered for special situations, but the default
generated report file, I have no difference between the test before and after
the modification

-- 
You are receiving this mail because:
You are the assignee for the bug.
Mime
View raw message