forked from simdjson/simdjson-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathParseAndSelectFixPathBenchMark.java
More file actions
49 lines (41 loc) · 1.78 KB
/
Copy pathParseAndSelectFixPathBenchMark.java
File metadata and controls
49 lines (41 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package org.simdjson;
import java.io.IOException;
import java.io.InputStream;
import java.util.concurrent.TimeUnit;
import org.openjdk.jmh.annotations.*;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
@State(Scope.Benchmark)
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.SECONDS)
public class ParseAndSelectFixPathBenchMark {
@Param({"/twitter.json"})
String fileName;
private byte[] buffer;
private final SimdJsonParser simdJsonParser = new SimdJsonParser();
private final ObjectMapper jacksonObjectMapper = new ObjectMapper();
private final SimdJsonParserWithFixPath simdJsonParserWithFixPath = new SimdJsonParserWithFixPath(
"statuses.0.user.default_profile", "statuses.0.user.screen_name",
"statuses.0.user.name", "statuses.0.user.id", "statuses.0.user.description",
"statuses.1.user.default_profile", "statuses.1.user.screen_name",
"statuses.1.user.name", "statuses.1.user.id", "statuses.1.user.description");
@Setup(Level.Trial)
public void setup() throws IOException {
try (InputStream is = ParseBenchmark.class.getResourceAsStream("/twitter.json")) {
buffer = is.readAllBytes();
}
System.out.println("VectorSpecies = " + VectorUtils.BYTE_SPECIES);
}
@Benchmark
public JsonValue parseMultiValuesForFixPaths_SimdJson() {
return simdJsonParser.parse(buffer, buffer.length);
}
@Benchmark
public String[] parseMultiValuesForFixPaths_SimdJsonParserWithFixPath() {
return simdJsonParserWithFixPath.parse(buffer, buffer.length);
}
@Benchmark
public JsonNode parseMultiValuesForFixPaths_Jackson() throws IOException {
return jacksonObjectMapper.readTree(buffer);
}
}