Skip to content

Commit 68d2cd8

Browse files
committed
added toJson benchmark
1 parent 55acfb3 commit 68d2cd8

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/test/java/com/arangodb/velocypack/Bench.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class Bench {
2828
public static class Data {
2929

3030
public final String str;
31+
public final VPackSlice slice;
3132
public final VPackSlice koko = buildKoko();
3233

3334
public Data() {
@@ -40,6 +41,9 @@ public Data() {
4041
} catch (Exception e) {
4142
throw new RuntimeException(e);
4243
}
44+
45+
VPackParser parser = new VPackParser.Builder().build();
46+
slice = parser.fromJson(str);
4347
}
4448

4549
public VPackSlice buildKoko() {
@@ -107,8 +111,15 @@ public void sliceGet(Data data, Blackhole bh) {
107111
@Benchmark
108112
public void fromJson(Data data, Blackhole bh) {
109113
VPackParser parser = new VPackParser.Builder().build();
110-
111114
VPackSlice slice = parser.fromJson(data.str);
112115
bh.consume(slice);
113116
}
117+
118+
@Benchmark
119+
public void toJson(Data data, Blackhole bh) {
120+
VPackParser parser = new VPackParser.Builder().build();
121+
String str = parser.toJson(data.slice);
122+
bh.consume(str);
123+
}
124+
114125
}

0 commit comments

Comments
 (0)