more benchmark
This commit is contained in:
parent
914aed5ab1
commit
27f6b550ad
@ -7,14 +7,17 @@ import org.openjdk.jmh.annotations.Benchmark;
|
||||
import org.openjdk.jmh.infra.Blackhole;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class Issue2407 {
|
||||
static String str;
|
||||
static byte[] utf8;
|
||||
|
||||
static {
|
||||
try {
|
||||
InputStream is = Issue2407.class.getClassLoader().getResourceAsStream("issue/issue2407.json");
|
||||
str = IOUtils.toString(is, "UTF-8");
|
||||
utf8 = str.getBytes(StandardCharsets.UTF_8);
|
||||
} catch (Throwable ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
@ -34,6 +37,13 @@ public class Issue2407 {
|
||||
);
|
||||
}
|
||||
|
||||
// @Benchmark
|
||||
public void parseArray1_utf8(Blackhole bh) {
|
||||
bh.consume(
|
||||
JSON.parseArray(utf8, Bean.class)
|
||||
);
|
||||
}
|
||||
|
||||
public class Bean {
|
||||
public String content;
|
||||
public String hostName;
|
||||
|
@ -14,7 +14,7 @@ public class Issue2407Test {
|
||||
}
|
||||
long millis = System.currentTimeMillis() - start;
|
||||
System.out.println("Issue2407-parseArray millis : " + millis);
|
||||
// zulu17.40.19 : 2639 2343
|
||||
// zulu17.40.19 : 2639 2557
|
||||
}
|
||||
}
|
||||
|
||||
@ -26,11 +26,25 @@ public class Issue2407Test {
|
||||
}
|
||||
long millis = System.currentTimeMillis() - start;
|
||||
System.out.println("Issue2407-parseArray1 millis : " + millis);
|
||||
// zulu17.40.19 : 2461
|
||||
// zulu17.40.19 : 2461 2312
|
||||
}
|
||||
}
|
||||
|
||||
public static void parseArray1_utf8() throws Exception {
|
||||
for (int j = 0; j < 5; j++) {
|
||||
long start = System.currentTimeMillis();
|
||||
for (int i = 0; i < COUNT; ++i) {
|
||||
benchmark.parseArray1_utf8(BH);
|
||||
}
|
||||
long millis = System.currentTimeMillis() - start;
|
||||
System.out.println("Issue2407-parseArray1_utf8 millis : " + millis);
|
||||
// zulu17.40.19 : 2422 2245
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
parseArray1();
|
||||
// parseArray();
|
||||
// parseArray1();
|
||||
parseArray1_utf8();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user