Skip to content

Commit

Permalink
Remove use of TypeFactory.defaultInstance()
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Oct 13, 2024
1 parent 998064b commit 1619e14
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/**
* Micro-benchmark for comparing performance of bean deserialization
*/
public final class DeserPerf
public final class YAMLDeserPerf
{
/*
/**********************************************************
Expand All @@ -18,7 +18,7 @@ public final class DeserPerf

private final int REPS;

private DeserPerf() {
private YAMLDeserPerf() {
// Let's try to guestimate suitable size
REPS = 9000;
}
Expand Down Expand Up @@ -115,28 +115,28 @@ public void test()
protected int testDeser(ObjectMapper mapper, byte[] input, int reps)
throws Exception
{
JavaType type = TypeFactory.defaultInstance().constructType(MediaItem.class);
JavaType type = mapper.constructType(MediaItem.class);
MediaItem item = null;
for (int i = 0; i < reps; ++i) {
item = mapper.readValue(input, 0, input.length, type);
}
return item.hashCode(); // just to get some non-optimizable number
}

protected int testDeser(JsonFactory jf, byte[] input, int reps)
protected int testDeser(JsonFactory f, byte[] input, int reps)
throws Exception
{
MediaItem item = null;
for (int i = 0; i < reps; ++i) {
JsonParser jp = jf.createParser(input);
item = MediaItem.deserialize(jp);
jp.close();
JsonParser p = f.createParser(input);
item = MediaItem.deserialize(p);
p.close();
}
return item.hashCode(); // just to get some non-optimizable number
}

public static void main(String[] args) throws Exception
{
new DeserPerf().test();
new YAMLDeserPerf().test();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.yaml.YAMLFactory;

public final class SerPerf
public final class YAMLSerPerf
{
/*
/**********************************************************
Expand All @@ -17,7 +17,7 @@ public final class SerPerf

private final int REPS;

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

public static void main(String[] args) throws Exception
{
new SerPerf().test();
new YAMLSerPerf().test();
}
}

0 comments on commit 1619e14

Please sign in to comment.