jmeter-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject [Bug 62426] Here are some Reduced ReportGenerator performance Code
Date Sat, 16 Jun 2018 14:42:27 GMT
https://bz.apache.org/bugzilla/show_bug.cgi?id=62426

--- Comment #4 from Felix Schumacher <felix.schumacher@internetallee.de> ---
(In reply to Allen from comment #0)
> 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 "" + "";

This would be possible and probably faster.

> 
> 
> 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.

String#format is slow, but simple concatenation doesn't help here, as the
labels are used for localization.

We probably would need a pre-compiled String#format mechanism, that would be
initialized ones and reused afterwards. Sadly, that is not possible with the
standard implementation of String#format.

> 
> 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

This one is needed, as the CSV file may contain new lines inside of quoted
text. If we remove it, we can not read in all of our self generated csv files.

> 
> 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

Do you have transaction samplers in your csv sample files?

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