Skip to content

Commit

Permalink
benchmark add library wast
Browse files Browse the repository at this point in the history
  • Loading branch information
wenshao committed Jan 1, 2025
1 parent 3e6f981 commit 838fd03
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ public void gson(Blackhole bh) throws Exception {
);
}

public void wast(Blackhole bh) {
bh.consume(io.github.wycst.wast.json.JSON.parseObject(utf8Bytes, Clients.class));
}

public static void main(String[] args) throws RunnerException {
Options options = new OptionsBuilder()
.include(ClientsParseUTF8Bytes.class.getName())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public void fastjson2(Blackhole bh) {
bh.consume(JSON.toJSONBytes(clients));
}

@Benchmark
public void wast(Blackhole bh) {
bh.consume(io.github.wycst.wast.json.JSON.toJsonBytes(clients));
}

public void jsonb(Blackhole bh) {
bh.consume(JSONB.toBytes(clients));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,28 @@ public static void fastjson2() {
}
long millis = System.currentTimeMillis() - start;
System.out.println("fastjson2 millis : " + millis);
// zulu17.40.19 : 2850 2815 2777 2770 2730 2704 2717 2661 2638 2603 2587 2662 2582 2441
// zulu17.40.19 : 2417
// oracle-jdk-17.0.6 :
// oracle-jdk-17.0.6_vec :
// oracle-jdk-17.0.6_reflect : 3566 3513 3476
}
}

public static void wast() {
for (int j = 0; j < 5; j++) {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000; ++i) {
benchmark.wast(BH);
}
long millis = System.currentTimeMillis() - start;
System.out.println("wast millis : " + millis);
// zulu17.40.19 : 2087
// oracle-jdk-17.0.6 :
// oracle-jdk-17.0.6_vec :
// oracle-jdk-17.0.6_reflect :
}
}

public static void dsljson() throws Exception {
for (int j = 0; j < 5; j++) {
long start = System.currentTimeMillis();
Expand All @@ -44,7 +59,8 @@ public static void jackson() throws Exception {
}

public static void main(String[] args) throws Exception {
fastjson2();
wast();
// fastjson2();
// dsljson();
// jackson();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,21 @@ public static void fastjson2() {
}
}

public static void wast() {
for (int j = 0; j < 5; j++) {
long start = System.currentTimeMillis();
for (int i = 0; i < 1000 * 1000; ++i) {
benchmark.wast(BH);
}
long millis = System.currentTimeMillis() - start;
System.out.println("ClientsWriteUTF8Bytes-wast millis : " + millis);
// zulu8.70.0.23 :
// zulu17.40.19 : 1364
// zulu17.40.19_vec :
// zulu17.40.19_reflect :
}
}

public static void fastjson2_str() {
for (int j = 0; j < 5; j++) {
long start = System.currentTimeMillis();
Expand Down Expand Up @@ -83,7 +98,8 @@ public static void jackson() throws Exception {
}

public static void main(String[] args) throws Exception {
fastjson2();
// fastjson2();
wast();
// jsonb();
// jsonb_beanToArray();
// fastjson2_str();
Expand Down

0 comments on commit 838fd03

Please sign in to comment.