A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/fabienrenaud/java-json-benchmark/commit/288a4e61496588ed4c0a80e1f107f34f9a2c985c below:

jodd · fabienrenaud/java-json-benchmark@288a4e6 · GitHub

File tree Expand file treeCollapse file tree 10 files changed

+62

-3

lines changed

Filter options

Expand file treeCollapse file tree 10 files changed

+62

-3

lines changed Original file line number Diff line number Diff line change

@@ -58,11 +58,13 @@ dependencies {

58 58

compile group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'

59 59

// nanojson

60 60

compile group: 'com.grack', name: 'nanojson', version: '1.2'

61 +

// jodd

62 +

compile group: 'org.jodd', name: 'jodd-json', version: '3.8.0'

61 63 62 64

// Test

63 65

testCompile group: 'junit', name: 'junit', version: '4.12'

64 66 65 -

// IMPORANT: Leave JMH at the end!

67 +

// IMPORTANT: Leave JMH at the end!

66 68

// JMH

67 69

compile group: 'org.openjdk.jmh', name: 'jmh-core', version: '1.15'

68 70

apt group: 'org.openjdk.jmh', name: 'jmh-generator-annprocess', version: '1.15'

Original file line number Diff line number Diff line change

@@ -74,4 +74,8 @@ public Object nanojson() throws Exception {

74 74

return null;

75 75

}

76 76 77 +

public Object jodd() throws Exception {

78 +

return null;

79 +

}

80 + 77 81

}

Original file line number Diff line number Diff line change

@@ -80,4 +80,10 @@ public Object dsljson() throws Exception {

80 80

public Object logansquare() throws Exception {

81 81

return LoganSquare.parse(JSON_SOURCE.nextInputStream(), JSON_SOURCE.pojoType());

82 82

}

83 + 84 +

@Benchmark

85 +

@Override

86 +

public Object jodd() throws Exception {

87 +

return JSON_SOURCE.provider().joddDeser().parse(JSON_SOURCE.nextString(), JSON_SOURCE.pojoType());

88 +

}

83 89

}

Original file line number Diff line number Diff line change

@@ -100,4 +100,10 @@ public Object logansquare() throws Exception {

100 100

LoganSquare.serialize(JSON_SOURCE.nextPojo(), baos);

101 101

return baos;

102 102

}

103 + 104 +

@Benchmark

105 +

@Override

106 +

public Object jodd() throws Exception {

107 +

return JSON_SOURCE.provider().joddSer().serialize(JSON_SOURCE.nextPojo());

108 +

}

103 109

}

Original file line number Diff line number Diff line change

@@ -12,9 +12,11 @@

12 12

*/

13 13

@JsonObject

14 14

@CompiledJson

15 +

@jodd.json.meta.JSON

15 16

public class Users {

16 17 17 18

@JsonField

19 +

@jodd.json.meta.JSON

18 20

public List<User> users;

19 21 20 22

@Override

@@ -79,9 +81,11 @@ public static final class User {

79 81

public double longitude;

80 82

@JsonField

81 83

@JsonAttribute(nullable = false)

84 +

@jodd.json.meta.JSON

82 85

public List<String> tags;

83 86

@JsonField

84 87

@JsonAttribute(nullable = false)

88 +

@jodd.json.meta.JSON

85 89

public List<Friend> friends;

86 90

@JsonField

87 91

public String greeting;

Original file line number Diff line number Diff line change

@@ -37,4 +37,8 @@ public interface JsonProvider<T> {

37 37

Map<String, Object> jsonioStreamOptions();

38 38 39 39

DslJson<T> dsljson();

40 + 41 +

jodd.json.JsonParser joddDeser();

42 + 43 +

jodd.json.JsonSerializer joddSer();

40 44

}

Original file line number Diff line number Diff line change

@@ -102,4 +102,28 @@ public Map<String, Object> jsonioStreamOptions() {

102 102

public DslJson<Users> dsljson() {

103 103

return dsljson;

104 104

}

105 + 106 +

@Override

107 +

public jodd.json.JsonParser joddDeser() {

108 +

return JODD_DESER.get();

109 +

}

110 + 111 +

@Override

112 +

public jodd.json.JsonSerializer joddSer() {

113 +

return JODD_SER.get();

114 +

}

115 + 116 +

private static final ThreadLocal<jodd.json.JsonParser> JODD_DESER = new ThreadLocal<jodd.json.JsonParser>() {

117 +

@Override

118 +

protected jodd.json.JsonParser initialValue() {

119 +

return new jodd.json.JsonParser();

120 +

}

121 +

};

122 + 123 +

private static final ThreadLocal<jodd.json.JsonSerializer> JODD_SER = new ThreadLocal<jodd.json.JsonSerializer>() {

124 +

@Override

125 +

protected jodd.json.JsonSerializer initialValue() {

126 +

return new jodd.json.JsonSerializer();

127 +

}

128 +

};

105 129

}

Original file line number Diff line number Diff line change

@@ -25,7 +25,8 @@ public enum BenchSupport {

25 25

new Libapi(Library.DSLJSON, Api.DATABIND),

26 26

new Libapi(Library.LOGANSQUARE, Api.DATABIND),

27 27

new Libapi(Library.JSONSIMPLE, Api.STREAM),

28 -

new Libapi(Library.NANOJSON, Api.STREAM)

28 +

new Libapi(Library.NANOJSON, Api.STREAM),

29 +

new Libapi(Library.JODD, Api.DATABIND)

29 30

);

30 31 31 32

private final List<Libapi> libapis;

Original file line number Diff line number Diff line change

@@ -22,7 +22,8 @@ public enum Library {

22 22

DSLJSON,

23 23

LOGANSQUARE,

24 24

JSONSIMPLE,

25 -

NANOJSON;

25 +

NANOJSON,

26 +

JODD;

26 27 27 28

public static Set<Library> fromCsv(String str) {

28 29

if (str == null || str.trim().isEmpty()) {

Original file line number Diff line number Diff line change

@@ -169,4 +169,11 @@ public void nanojson() throws Exception {

169 169

test(Library.NANOJSON, BENCH.nanojson());

170 170

}

171 171

}

172 + 173 +

@Test

174 +

public void jodd() throws Exception {

175 +

for (int i = 0; i < ITERATIONS; i++) {

176 +

test(Library.JODD, BENCH.jodd());

177 +

}

178 +

}

172 179

}

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4