Skip to content

Commit f5bed75

Browse files
committed
Improve benchmark
1 parent d1bd778 commit f5bed75

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

benchmark/jmh/src/main/java/com/github/skjolber/jsonfilter/jmh/CveFilterBenchmark.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import com.github.skjolber.jsonfilter.base.AbstractPathJsonFilter.FilterType;
2727
import com.github.skjolber.jsonfilter.core.AnyPathJsonFilter;
2828
import com.github.skjolber.jsonfilter.core.DefaultJsonLogFilterBuilder;
29+
import com.github.skjolber.jsonfilter.core.FullPathJsonFilter;
2930
import com.github.skjolber.jsonfilter.core.MaxSizeJsonFilter;
3031
import com.github.skjolber.jsonfilter.core.MaxStringLengthJsonFilter;
3132
import com.github.skjolber.jsonfilter.core.MaxStringLengthMaxSizeJsonFilter;
@@ -64,10 +65,11 @@ public class CveFilterBenchmark {
6465
private JacksonBenchmarkRunner jacksonPathMaxSizeMaxStringLengthJsonFilter;
6566
private BenchmarkRunner<JsonFilter> pathMaxSizeMaxStringLengthJsonFilter;
6667

67-
private BenchmarkRunner<JsonFilter> multiPathMaxStringLengthJsonFilter;
68+
private BenchmarkRunner<JsonFilter> pathMaxStringLengthJsonFilter;
6869
private BenchmarkRunner<JacksonJsonFilter> pathMaxStringLengthJacksonJsonFilter;
6970

7071
private BenchmarkRunner<JsonFilter> anyPathJsonFilter;
72+
private BenchmarkRunner<JsonFilter> fullPathJsonFilter;
7173

7274
private BenchmarkRunner<JsonFilter> maxStringLengthJsonFilter;
7375
private BenchmarkRunner<JacksonJsonFilter> maxStringLengthJacksonJsonFilter;
@@ -86,7 +88,7 @@ public class CveFilterBenchmark {
8688

8789
private BenchmarkRunner<JsonFilter> removeWhitespaceJsonFilter;
8890

89-
//@Param(value={"2KB","8KB","14KB","22KB","30KB","50KB","70KB","100KB","200KB"})
91+
// @Param(value={"2KB","8KB","14KB","22KB","30KB","50KB","70KB","100KB","200KB"})
9092
@Param(value={"8KB"})
9193
private String fileName;
9294
private final boolean prettyPrinted = false;
@@ -102,7 +104,7 @@ public void init() throws Exception {
102104
pathMaxSizeMaxStringLengthJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new PathMaxSizeMaxStringLengthJsonFilter(maxStringLength, size, -1, anon, prune), prettyPrinted);
103105

104106
pathMaxStringLengthJacksonJsonFilter = new JacksonBenchmarkRunner(file, true, (JacksonJsonFilter) new JacksonJsonLogFilterBuilder().withMaxStringLength(maxStringLength).withAnonymize(anon).withPrune(prune).build(), prettyPrinted);
105-
multiPathMaxStringLengthJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new DefaultJsonLogFilterBuilder().withMaxStringLength(maxStringLength).withAnonymize(anon).withPrune(prune).build(), prettyPrinted);
107+
pathMaxStringLengthJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new DefaultJsonLogFilterBuilder().withMaxStringLength(maxStringLength).withAnonymize(anon).withPrune(prune).build(), prettyPrinted);
106108

107109
maxStringLengthJacksonJsonFilter = new JacksonBenchmarkRunner(file, true, (JacksonJsonFilter) new JacksonJsonLogFilterBuilder().withMaxStringLength(maxStringLength).build(), prettyPrinted);
108110
maxStringLengthJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new MaxStringLengthJsonFilter(maxStringLength), prettyPrinted);
@@ -119,6 +121,7 @@ public void init() throws Exception {
119121
removeWhitespaceJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new RemoveWhitespaceJsonFilter(), prettyPrinted);
120122

121123
anyPathJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new AnyPathJsonFilter(size, new String[] {"//version"}, null), prettyPrinted);
124+
fullPathJsonFilter = new BenchmarkRunner<JsonFilter>(file, true, new FullPathJsonFilter(size, anon, null), prettyPrinted);
122125

123126
// other filters
124127
var singlePathJsonMasker = JsonMasker.getMasker(
@@ -148,7 +151,7 @@ public long all_jackson() throws IOException {
148151

149152
@Benchmark
150153
public long all_core() throws IOException {
151-
return multiPathMaxStringLengthJsonFilter.benchmarkBytes();
154+
return pathMaxStringLengthJsonFilter.benchmarkBytes();
152155
}
153156

154157
@Benchmark
@@ -215,7 +218,11 @@ public long anon_any_jsonMask() throws IOException {
215218
public long anon_full_jsonMask() throws IOException {
216219
return fullPathJsonMaskerJsonFilter.benchmarkBytesAsArray();
217220
}
218-
221+
222+
@Benchmark
223+
public long anon_full_core() throws IOException {
224+
return fullPathJsonFilter.benchmarkBytesAsArray();
225+
}
219226

220227
public static void main(String[] args) throws RunnerException {
221228
Options opt = new OptionsBuilder()

0 commit comments

Comments
 (0)