Skip to content

Commit 1619e14

Browse files
committed
Remove use of TypeFactory.defaultInstance()
1 parent 998064b commit 1619e14

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

yaml/src/test/java/perf/DeserPerf.java renamed to yaml/src/test/java/perf/YAMLDeserPerf.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
/**
99
* Micro-benchmark for comparing performance of bean deserialization
1010
*/
11-
public final class DeserPerf
11+
public final class YAMLDeserPerf
1212
{
1313
/*
1414
/**********************************************************
@@ -18,7 +18,7 @@ public final class DeserPerf
1818

1919
private final int REPS;
2020

21-
private DeserPerf() {
21+
private YAMLDeserPerf() {
2222
// Let's try to guestimate suitable size
2323
REPS = 9000;
2424
}
@@ -115,28 +115,28 @@ public void test()
115115
protected int testDeser(ObjectMapper mapper, byte[] input, int reps)
116116
throws Exception
117117
{
118-
JavaType type = TypeFactory.defaultInstance().constructType(MediaItem.class);
118+
JavaType type = mapper.constructType(MediaItem.class);
119119
MediaItem item = null;
120120
for (int i = 0; i < reps; ++i) {
121121
item = mapper.readValue(input, 0, input.length, type);
122122
}
123123
return item.hashCode(); // just to get some non-optimizable number
124124
}
125125

126-
protected int testDeser(JsonFactory jf, byte[] input, int reps)
126+
protected int testDeser(JsonFactory f, byte[] input, int reps)
127127
throws Exception
128128
{
129129
MediaItem item = null;
130130
for (int i = 0; i < reps; ++i) {
131-
JsonParser jp = jf.createParser(input);
132-
item = MediaItem.deserialize(jp);
133-
jp.close();
131+
JsonParser p = f.createParser(input);
132+
item = MediaItem.deserialize(p);
133+
p.close();
134134
}
135135
return item.hashCode(); // just to get some non-optimizable number
136136
}
137137

138138
public static void main(String[] args) throws Exception
139139
{
140-
new DeserPerf().test();
140+
new YAMLDeserPerf().test();
141141
}
142142
}

yaml/src/test/java/perf/SerPerf.java renamed to yaml/src/test/java/perf/YAMLSerPerf.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
import com.fasterxml.jackson.databind.ObjectMapper;
88
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;
99

10-
public final class SerPerf
10+
public final class YAMLSerPerf
1111
{
1212
/*
1313
/**********************************************************
@@ -17,7 +17,7 @@ public final class SerPerf
1717

1818
private final int REPS;
1919

20-
private SerPerf() throws Exception
20+
private YAMLSerPerf() throws Exception
2121
{
2222
// Let's try to guesstimate suitable size...
2323
REPS = 6000;
@@ -141,6 +141,6 @@ protected int testObjectSer(JsonFactory jf, MediaItem value, int reps, ByteArray
141141

142142
public static void main(String[] args) throws Exception
143143
{
144-
new SerPerf().test();
144+
new YAMLSerPerf().test();
145145
}
146146
}

0 commit comments

Comments
 (0)