diff --git a/README b/README index 610ac12..58e914c 100644 --- a/README +++ b/README @@ -1 +1,21 @@ -Look in the "tpc" directory for source code; or see https://github.com/eishay/jvm-serializers/wiki for current results. +(RuedigerMoeller =>) + +My current results: + +https://github.com/RuedigerMoeller/fast-serialization/wiki/TestPage + +My modifications: + +* The original project actually used the MINIMUM runtime for each benchmark thereby completely excluding GC related effects. +I changed it to measure the average results of all runs (excluding warmup) + +* I start a new VM for each benchmark run instead of running all in a single VM + +* I limit test runs by time not by number of iterations + +* I somewhat categorized serializers (full graph, generic, manually adoption, JSON/Binary, crossplatform ..). A lot of +comparing apples and oranges is going on there .. + +* beautified charts + + diff --git a/tpc/README b/tpc/README index 600ac2d..bfc17a0 100644 --- a/tpc/README +++ b/tpc/README @@ -1,16 +1,37 @@ Requirements: - GNU Make 3.81+ -- JDK 1.5+ +- JDK 1.7+ + +for windows install cygwin with make+bash features To compile: - make + make + (if you run in trouble its usually because of CRLF dirt) E.g. scalac did not run because it was CRLF -To run: - ./run -help +To run -To run and generate charts with all serializers: (For official results, add -trials=500) - ./run -chart -include=`cat serializers.txt | tr "\\n" ","` data/media.1.cks + bash run-bench.sh + +Parameters of the default run are hardcoded in run-bench.sh +To update results of subset of serializers -To generate bindings for schema files, see top of "Makefile" for -instructions on what to put into "Config.mk". + bash run-bench.sh serializer1,serializer2,.. + +How this works: + + the project was somewhat messy, i probably contributed to that .. but its easier to manage now. + I removed the config files to avoid problems when serializers rename or are un/commented. Additionally + each benchmark runs in a separate VM. + + 1) the run-bench.sh uses class BenchmarkExporter.java to get a ',' separated list of all serializers to run. + All benchmarks registered in the BenchMarkRunner.java class a run be default. + 2) after each bench finished, the mk-stats.sh script aggregates the results found in ./results/tmp to ./results.txt + the the class StatsCruncher.java creates a Textile style report. + To modify the report output, directly edit the StatsCruncher.java . You are welcome to enhance this using + some templating/configuration files. + You can copy the report.textile directly to github wiki in textile-mode. + 3) You can run the mk-stats.sh script again without having to re-run the benchmarks if you want to add + custom query charts. + 4) to filter out certain libraries, do not uncomment them in BenchMarkRunner.java (except they fail), better + edit StatsCruncher.java to exclude them. \ No newline at end of file diff --git a/tpc/attic/README_old b/tpc/attic/README_old new file mode 100644 index 0000000..af4a8f1 --- /dev/null +++ b/tpc/attic/README_old @@ -0,0 +1,16 @@ +Requirements: +- GNU Make 3.81+ +- JDK 1.7+ + +To compile: + make + +To run: + ./run -help + +To run and generate charts with all serializers: (For official results, add -trials=500) + ./run -chart -include=`cat serializers.txt | tr "\\n" ","` data/media.1.cks + + +To generate bindings for schema files, see top of "Makefile" for +instructions on what to put into "Config.mk". diff --git a/tpc/run b/tpc/attic/run old mode 100755 new mode 100644 similarity index 100% rename from tpc/run rename to tpc/attic/run diff --git a/tpc/run-stream b/tpc/attic/run-stream old mode 100755 new mode 100644 similarity index 100% rename from tpc/run-stream rename to tpc/attic/run-stream diff --git a/tpc/run-wiki b/tpc/attic/run-wiki similarity index 100% rename from tpc/run-wiki rename to tpc/attic/run-wiki diff --git a/tpc/serializers.txt b/tpc/attic/serializers.txt similarity index 100% rename from tpc/serializers.txt rename to tpc/attic/serializers.txt diff --git a/tpc/data/media.1.cks-result.txt b/tpc/data/media.1.cks-result.txt new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/tpc/data/media.1.cks-result.txt @@ -0,0 +1 @@ + diff --git a/tpc/lib/fst-1.40-onejar.jar b/tpc/lib/fst-1.40-onejar.jar deleted file mode 100644 index fbbeb0a..0000000 Binary files a/tpc/lib/fst-1.40-onejar.jar and /dev/null differ diff --git a/tpc/lib/fst-1.42.jar b/tpc/lib/fst-1.42.jar new file mode 100644 index 0000000..141e884 Binary files /dev/null and b/tpc/lib/fst-1.42.jar differ diff --git a/tpc/mk-stats.sh b/tpc/mk-stats.sh new file mode 100644 index 0000000..b44407e --- /dev/null +++ b/tpc/mk-stats.sh @@ -0,0 +1,21 @@ +#! /usr/bin/env bash + +echo "" > stats.txt + +FILES=./results/tmp/*-result.txt +for f in $FILES +do + awk '/./{line=$0} END{print line}' $f >> stats.txt +done + +cpgen=$(cat build/gen-cp) +cplib=$(cat build/lib-cp) +sep=':' +# cygwin +case "`uname`" in + CYGWIN*) sep=';' ;; +esac + +cp=./build/bytecode/main$sep$cpgen$sep$cplib + +java -cp $cp serializers.StatsCruncher diff --git a/tpc/result.txt b/tpc/result.txt deleted file mode 100644 index 699b9d1..0000000 --- a/tpc/result.txt +++ /dev/null @@ -1,127 +0,0 @@ -java version "1.7.0_51" -Java(TM) SE Runtime Environment (build 1.7.0_51-b13) -Java HotSpot(TM) 64-Bit Server VM (build 24.51-b03, mixed mode) - -SIMPLE/GENERIC:
Serializes any POJO tree without class specific optimization. Serialized classes are known in advance. No cycle detection/shared object detection is done. - -Checking correctness... -[done] -Pre-warmup... java-built-in hessian kryo fast-serialization jboss-serialization jboss-marshalling-river protostuff msgpack-databind json/jackson/databind json/jackson/db-afterburner json/protostuff-runtime json/google-gson/databind json/svenson-databind json/flexjson/databind json/fastjson/databind smile/jackson/databind smile/jackson/db-afterburner bson/jackson/databind xml/xstream+c xml/jackson/databind-aalto -[done] - -pre. create ser deser total size +dfl -java-built-in 63 5838 30208 36046 889 514 -hessian 63 3881 6176 10057 501 313 -kryo 63 655 838 1493 212 132 -fast-serialization 63 704 864 1568 252 166 -jboss-serialization 63 6466 6643 13110 932 582 -jboss-marshalling-river 63 4656 23892 28548 694 400 -protostuff 82 495 732 1227 239 150 -msgpack-databind 62 830 1370 2200 233 146 -json/jackson/databind 62 1895 2600 4496 485 261 -json/jackson/db-afterburner 63 1513 1988 3501 485 261 -json/protostuff-runtime 63 1532 2138 3670 469 243 -json/google-gson/databind 63 5633 4844 10477 486 259 -json/svenson-databind 63 5270 10358 15628 495 272 -json/flexjson/databind 63 19445 25394 44838 503 273 -json/fastjson/databind 63 1316 1149 2465 486 262 -smile/jackson/databind 63 1768 1891 3659 338 241 -smile/jackson/db-afterburner 64 1448 1492 2940 352 252 -bson/jackson/databind 64 5376 6812 12188 506 286 -xml/xstream+c 64 6476 13505 19981 487 244 -xml/jackson/databind-aalto 63 3001 5516 8517 683 286 - - - - - - - - - -DEFAULT:
Serializes any object trees, cycle detection enabled. Nothing is known in advance about the classes to serialize. Only serializers supporting full object graph restauration are included. - -Checking correctness... -[done] -Pre-warmup... java-built-in-serializer hessian kryo-serializer fast-serialization-shared jboss-serialization -[done] - -pre. create ser deser total size +dfl -java-built-in-serializer 64 5723 29259 34982 889 514 -hessian 64 3611 6169 9780 501 313 -kryo-serializer 64 1711 1499 3210 311 198 -fast-serialization-shared 64 1621 1592 3212 341 212 -jboss-serialization 64 6442 6339 12781 932 582 - - - - - - - - - -SIMPLE/SPECIFC: Serializes only specific classes using code generation or other special knowledge about the class. - -Checking correctness... -[done] -Pre-warmup... kryo-opt wobly wobly-compact protobuf protostuff protobuf/protostuff thrift thrift-compact avro json/json-lib-databind json/jsonij-jpath -[done] - -pre. create ser deser total size +dfl -kryo-opt 64 658 864 1522 209 129 -wobly 43 886 536 1422 251 151 -wobly-compact 43 903 569 1471 225 139 -protobuf 130 1225 701 1926 239 149 -protostuff 82 488 678 1166 239 150 -protobuf/protostuff 83 598 692 1290 239 149 -thrift 126 1796 795 2591 349 197 -thrift-compact 126 1555 963 2518 240 148 -avro 89 1616 1415 3031 221 133 -json/json-lib-databind 63 26330 103150 129479 485 263 -json/jsonij-jpath 63 38015 12325 50339 478 259 - - - - - - - - - -MANUAL:
Serializes only specific classes using hand written serialization code. - -Checking correctness... -[done] -Pre-warmup... java-manual kryo-manual protostuff-manual avro-generic json/jackson/manual json/protostuff-manual json/google-gson/manual json/json.simple/manual json/json-smart/manual/tree json/org.json/manual/tree json/argo-manual/tree smile/jackson/manual bson/mongodb xml/woodstox-manual xml/aalto-manual xml/xstream+c-woodstox xml/xstream+c-aalto xml/xstream+c-fastinfo xml/javolution xml/fastinfo-manual -[done] - -pre. create ser deser total size +dfl -java-manual 63 847 632 1480 255 147 -kryo-manual 63 555 616 1171 211 131 -protostuff-manual 63 465 711 1176 239 150 -avro-generic 379 1822 1125 2947 221 133 -json/jackson/manual 63 1097 1539 2636 468 253 -json/protostuff-manual 63 1345 1816 3161 449 233 -json/google-gson/manual 63 3696 3756 7452 468 253 -json/json.simple/manual 63 6184 8059 14243 495 269 -json/json-smart/manual/tree 63 5314 4088 9402 495 269 -json/org.json/manual/tree 63 6989 8413 15403 485 259 -json/argo-manual/tree 63 66575 14578 81153 485 263 -smile/jackson/manual 63 939 1092 2031 341 244 -bson/mongodb 64 3422 7762 11184 495 278 -xml/woodstox-manual 63 3159 4578 7737 653 304 -xml/aalto-manual 63 2077 3093 5170 653 304 -xml/xstream+c-woodstox 63 5638 10506 16144 525 273 -xml/xstream+c-aalto 63 4893 8912 13805 525 273 -xml/xstream+c-fastinfo 63 8451 7971 16422 345 264 -xml/javolution 64 5544 8538 14082 504 263 -xml/fastinfo-manual 64 6959 5420 12379 377 284 - - - - - - - - diff --git a/tpc/run-bench.sh b/tpc/run-bench.sh new file mode 100644 index 0000000..569bfbc --- /dev/null +++ b/tpc/run-bench.sh @@ -0,0 +1,54 @@ +#! /usr/bin/env bash + +# added this, because the other runscripts did not work for me with recent cygwin installation + +mem=-Xmx256m +clz=serializers.BenchmarkRunner + +cpgen=$(cat build/gen-cp) +cplib=$(cat build/lib-cp) +sep=':' +# cygwin +case "`uname`" in + CYGWIN*) sep=';' ;; +esac + +cp=./build/bytecode/main$sep$cpgen$sep$cplib + +# for low run-to-run jitter (anyway expect ~3% run-to-run jitter) +# testTime=60000 +# warmupTime=60000 +# turn off turbo boost and any other kind of dynamic clock scaling + +testTime=10000 +warmupTime=15000 +iter=2000 + +mkdir ./results/tmp &> /dev/null + +if [ -n "$1" ]; then + sentence=$1 +else + rm ./results/tmp/*.txt + sentence=$(java -cp $cp serializers.BenchMarkExporter) # just grab all serializers +fi + +sentence=${sentence//,/$'\n'} # change the colons to white space +for word in $sentence +do + echo "running $word .." + file=$word-result.txt + file=./results/tmp/${file//\//-} # change '/' to '-' + echo $word > $file + java $mem -cp $cp $clz -iterations=$iter -warmup-time=$warmupTime -testRunMillis=$testTime -include=$word data/media.1.cks >> $file +done + +# find files with no numbers => errors +echo "" +echo "=====================================================================================" +echo "errors:" +find ./results/tmp/. -print -type f -name "*.txt" -exec tail -1 {} \; | grep -B 1 create +echo "=====================================================================================" +echo "" + +exec ./mk-stats.sh \ No newline at end of file diff --git a/tpc/run-cygwin.sh b/tpc/run-cygwin.sh deleted file mode 100644 index c893562..0000000 --- a/tpc/run-cygwin.sh +++ /dev/null @@ -1,50 +0,0 @@ -#! /usr/bin/env bash - -# added this, because the other runscripts did not work for me with recent cygwin installation - -mem=-Xmx256m -clz=serializers.BenchmarkRunner - -cpgen=$(cat build/gen-cp) -cplib=$(cat build/lib-cp) -sep=';' -cp=./build/bytecode/main$sep$cpgen$sep$cplib - -java -version &> result.txt - -#echo "" -#echo "CPGEN:" -#echo $cpgen -#echo "" -#echo "CPLIB:" -#echo $cplib -#echo "" -#echo "CP:" -#echo $cp -#echo "" - - -# SIMPLE/GENERIC -echo "" >> result.txt -echo "SIMPLE/GENERIC:
Serializes any POJO tree without class specific optimization. Serialized classes are known in advance. No cycle detection/shared object detection is done." >> result.txt -echo "" >> result.txt -java $mem -cp $cp $clz -trials=500 -chart -include=java-built-in,hessian,kryo,fast-serialization,jboss-serialization,jboss-marshalling-river,protostuff,msgpack-databind,json/jackson/databind,json/jackson/db-afterburner,json/google-gson/databind,json/svenson-databind,json/flexjson/databind,json/fastjson/databind,smile/jackson/databind,smile/jackson/db-afterburner,smile/protostuff-runtime,bson/jackson/databind,xml/xstream+c,xml/jackson/databind-aalto,json/protostuff-runtime data/media.1.cks >> result.txt - -# DEFAULT -echo "" >> result.txt -echo "DEFAULT:
Serializes arbitrary object graphs, cycle detection enabled. Nothing is known in advance about the classes to serialize. Only serializers supporting full object graph serialization are included." >> result.txt -echo "" >> result.txt -java $mem -cp $cp $clz -trials=500 -chart -include=java-built-in-serializer,hessian,kryo-serializer,fast-serialization-shared,jboss-serialization data/media.1.cks >> result.txt - -# SIMPLE/SPECIFC: Serializes only specific classes using code generation or other special knowledge about the class. -echo "" >> result.txt -echo "SIMPLE/SPECIFC: Serializes only specific classes using code generation or other special knowledge about the class." >> result.txt -echo "" >> result.txt -java $mem -cp $cp $clz -trials=500 -chart -include=wobly,wobly-compact,kryo-opt,protobuf,protostuff,protobuf/protostuff,thrift,thrift-compact,avro,json/json-lib-databind,json/jsonij-jpath,json/jsonpath/json.simple data/media.1.cks >> result.txt - -# MANUAL: Serializes only specific classes using hand written serialization code. -echo "" >> result.txt -echo "MANUAL:
Serializes only specific classes using hand written serialization code." >> result.txt -echo "" >> result.txt -java $mem -cp $cp $clz -hidden -trials=500 -chart -include=java-manual,kryo-manual,protostuff-manual,json/jackson/manual,json/jackson/tree,json/protostuff-manual,json/google-gson/manual,json/google-gson/manual/tree,json/json.simple/manual,json/json.simple/manual/tree,json/json-smart/manual/tree,json/org.json/manual/tree,json/jsonij-manual/tree,json/argo-manual/tree,smile/jackson/manual,smile/protostuff-manual,bson/mongodb,xml/woodstox-manual,xml/aalto-manual,xml/fastinfo-manual,xml/xstream+c-woodstox,xml/xstream+c-aalto,xml/xstream+c-fastinfo,xml/javolution,avro-generic data/media.1.cks >> result.txt - diff --git a/tpc/src/serializers/BenchMarkExporter.java b/tpc/src/serializers/BenchMarkExporter.java new file mode 100644 index 0000000..fc93c26 --- /dev/null +++ b/tpc/src/serializers/BenchMarkExporter.java @@ -0,0 +1,70 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 10:09 + * To change this template use File | Settings | File Templates. + */ + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; +import java.util.Set; + +/** + * tweak to generate a string containing all registered benchmarks and extract bench feature data. called by run script + */ +public class BenchMarkExporter extends BenchmarkRunner { + + String alltests = ""; // ',' separated + HashMap featureMap = new HashMap<>(); // have to map back after running .. sigh + + public BenchMarkExporter() { + runBenchmark(new String[0]); + } + + protected void runBenchmark(String[] args) + { + TestGroups groups = new TestGroups(); + addTests(groups); + Set media = groups.groupMap.get("media").entryNames; + for (Iterator iterator = media.iterator(); iterator.hasNext(); ) { + String next = iterator.next().trim(); + if ( ! next.equals("cks") && ! next.equals("cks-text") ) // used to read data, exclude + alltests += next+ (iterator.hasNext() ? "," : ""); + SerFeatures features = groups.groupMap.get("media").getSerMap().get(next).getFeatures(); +// System.out.println("serializer:"+next+" miscFeatures: "+miscFeatures); + featureMap.put(next, features); + } + } + + public String getAlltests() { + return alltests; + } + + public HashMap getFeatureMap() { + return featureMap; + } + + public static void main(String arg[]) { + System.out.println(new BenchMarkExporter().getAlltests()); + } + +} diff --git a/tpc/src/serializers/BenchmarkBase.java b/tpc/src/serializers/BenchmarkBase.java index 0f9d533..6447287 100644 --- a/tpc/src/serializers/BenchmarkBase.java +++ b/tpc/src/serializers/BenchmarkBase.java @@ -11,14 +11,14 @@ */ abstract class BenchmarkBase { - public final static int DEFAULT_ITERATIONS = 2000; - public final static int DEFAULT_TRIALS = 500; + public final static int DEFAULT_ITERATIONS = 2000; + public final static int DEFAULT_TEST_RUN_MILLIS = 10000; // 10 seconds /** * Number of milliseconds to warm up for each operation type for each serializer. Let's * start with 3 seconds. */ - final static long DEFAULT_WARMUP_MSECS = 3000; + final static long DEFAULT_WARMUP_MSECS = 10000; // These tests aren't included by default. Use the "-hidden" flag to enable them. protected static final HashSet HIDDEN = new HashSet(); @@ -54,7 +54,7 @@ public enum measurements protected final static class Params { public int iterations = DEFAULT_ITERATIONS; - public int trials = DEFAULT_TRIALS; + public int testRunMillis = DEFAULT_TEST_RUN_MILLIS; public long warmupTime = DEFAULT_WARMUP_MSECS; public boolean prewarm = true; public Boolean filterIsInclude; @@ -171,19 +171,19 @@ else if (option.equals("iterations")) { System.exit(1); } } - else if (option.equals("trials")) { + else if (option.equals("testRunMillis")) { if (value == null) { - System.err.println("The \"trials\" option requires a value."); + System.err.println("The \"testRunMillis\" option requires a value."); System.exit(1); } try { - params.trials = Integer.parseInt(value); + params.testRunMillis = Integer.parseInt(value); } catch (NumberFormatException ex) { - System.err.println("Invalid value for \"trials\" option: \"" + value + "\""); + System.err.println("Invalid value for \"testRunMillis\" option: \"" + value + "\""); System.exit(1); } - if (params.trials < 1) { - System.err.println("Invalid value for \"trials\" option: \"" + value + "\""); + if (params.testRunMillis < 1) { + System.err.println("Invalid value for \"testRunMillis\" option: \"" + value + "\""); System.exit(1); } } @@ -238,7 +238,7 @@ else if (option.equals("help")) { System.out.println(); System.out.println("Options:"); System.out.println(" -iterations=n [default=" + DEFAULT_ITERATIONS + "]"); - System.out.println(" -trials=n [default=" + DEFAULT_TRIALS + "]"); + System.out.println(" -testRunMillis=n [default=" + DEFAULT_TEST_RUN_MILLIS + "ms]"); System.out.println(" -warmup-time=millis [default=" + DEFAULT_WARMUP_MSECS + "]"); System.out.println(" -skip-pre-warmup (don't warm all serializers before the first measurement)"); System.out.println(" -chart (generate a Google Chart URL for the results)"); @@ -483,18 +483,20 @@ protected EnumMap> runMeasurements(PrintWr * Should only warm things for the serializer that we test next: HotSpot JIT will * otherwise spent most of its time optimizing slower ones... */ - warmTest(runner, params.warmupTime, testCreate); + warmTest(runner, params.warmupTime/3, testCreate); doGc(); - double timeCreate = runner.runTakeMin(params.trials, testCreate, params.iterations * 100); // do more iteration for object creation because of its short time + // ruediger: turns out startup/init time is pretty equal for all tests. + // No need to spend too much time here + double timeCreate = runner.runWithTimeMeasurement(params.testRunMillis / 3, testCreate, params.iterations); warmTest(runner, params.warmupTime, testSerialize); doGc(); - double timeSerialize = runner.runTakeMin(params.trials, testSerialize, params.iterations); - + double timeSerialize = runner.runWithTimeMeasurement(params.testRunMillis, testSerialize, params.iterations); + doGc(); - double timeDeserialize = runner.runTakeMin(params.trials, testDeserialize, params.iterations); + double timeDeserialize = runner.runWithTimeMeasurement(params.testRunMillis, testDeserialize, params.iterations); double totalTime = timeSerialize + timeDeserialize; diff --git a/tpc/src/serializers/BenchmarkRunner.java b/tpc/src/serializers/BenchmarkRunner.java index 6c42632..c793f9e 100644 --- a/tpc/src/serializers/BenchmarkRunner.java +++ b/tpc/src/serializers/BenchmarkRunner.java @@ -9,6 +9,7 @@ import serializers.json.*; import serializers.msgpack.MsgPack; import serializers.protobuf.Protobuf; +import serializers.protobuf.ProtobufJson; import serializers.protostuff.Protostuff; import serializers.protostuff.ProtostuffJson; import serializers.xml.ExiExificient; @@ -26,7 +27,6 @@ public static void main(String[] args) { new BenchmarkRunner().runBenchmark(args); } - @Override protected void addTests(TestGroups groups) { // Binary Formats; language-specific ones @@ -34,7 +34,7 @@ protected void addTests(TestGroups groups) JavaManual.register(groups); // 06-May-2013, tatu: way too slow, commenting out for now, can add in slow section? -// Scala.register(groups); + Scala.register(groups); // ruediger: let them face the truth :-). Not a problem as now time based test duration // hessian, kryo and wobly are Java object serializations Hessian.register(groups); Kryo.register(groups); @@ -69,10 +69,10 @@ protected void addTests(TestGroups groups) JavaxJsonStreamGlassfish.register(groups); JsonTwoLattes.register(groups); ProtostuffJson.register(groups); -// too slow, why bother: -// ProtobufJson.register(groups); + + ProtobufJson.register(groups); JsonGsonManual.register(groups); -// JsonGsonTree.register(groups); + JsonGsonTree.register(groups); JsonGsonDatabind.register(groups); JsonSvensonDatabind.register(groups); FlexjsonDatabind.register(groups); diff --git a/tpc/src/serializers/FastSerialization.java b/tpc/src/serializers/FastSerialization.java index e493703..31f461f 100644 --- a/tpc/src/serializers/FastSerialization.java +++ b/tpc/src/serializers/FastSerialization.java @@ -34,24 +34,52 @@ public static void register (TestGroups groups) { } private static void register (TestGroup group, Transformer transformer) { - group.add(transformer, new BasicSerializer("fast-serialization",true)); - group.add(transformer, new BasicSerializer("fast-serialization-shared",false)); + group.add(transformer, new BasicSerializer("fst-flat-pre",true,true), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "fst in unshared mode with preregistered classes" + ) + ); + + group.add(transformer, new BasicSerializer("fst-flat",true,false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "fst default, but unshared mode" + ) + ); + group.add(transformer, new BasicSerializer("fst",false,false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "default: JDK serialization drop-in-replacement mode" + ) + ); + } // ------------------------------------------------------------ // Serializers /** - * setup similar to kryo: all classes registered, unshared mode, unsafe disabled (does not help anyway for this bench) + * setup similar to kryo */ public static class BasicSerializer extends Serializer { - final static FSTConfiguration conf; + final static FSTConfiguration confUnsharedUnregistered; + final static FSTConfiguration confUnsharedRegister; final static FSTConfiguration confShared; static { // System.setProperty("fst.unsafe", "true"); - conf = FSTConfiguration.createDefaultConfiguration(); - conf.setShareReferences(false); - conf.registerClass( + confUnsharedUnregistered = FSTConfiguration.createDefaultConfiguration(); + confUnsharedUnregistered.setShareReferences(false); + + confUnsharedRegister = FSTConfiguration.createDefaultConfiguration(); + confUnsharedRegister.setShareReferences(false); + confUnsharedRegister.registerClass( Image.Size.class, Image.class, Media.Player.class, @@ -59,19 +87,27 @@ public static class BasicSerializer extends Serializer { MediaContent[].class, MediaContent.class, MediaContent.class); + confShared = FSTConfiguration.createDefaultConfiguration(); } FSTObjectInput objectInput; FSTObjectOutput objectOutput; + boolean unshared; String name; + Class type[] = { MediaContent.class }; - public BasicSerializer (String name, boolean unshared) { - conf.setShareReferences(!unshared); + public BasicSerializer (String name, boolean flat, boolean register) { this.name = name; - if ( unshared ) { - objectInput = new FSTObjectInputNoShared(conf); - objectOutput = new FSTObjectOutputNoShared(conf); + this.unshared = flat; + if ( flat ) { + if ( register ) { + objectInput = new FSTObjectInputNoShared(confUnsharedRegister); + objectOutput = new FSTObjectOutputNoShared(confUnsharedRegister); + } else { + objectInput = new FSTObjectInputNoShared(confUnsharedUnregistered); + objectOutput = new FSTObjectOutputNoShared(confUnsharedUnregistered); + } } else { objectInput = new FSTObjectInput(confShared); objectOutput = new FSTObjectOutput(confShared); @@ -86,7 +122,7 @@ public T deserialize (byte[] array) { private Object deserializeInternal(byte[] array) { try { objectInput.resetForReuseUseArray(array); - return objectInput.readObject(); + return objectInput.readObject(type); } catch (Throwable e) { e.printStackTrace(); } @@ -94,13 +130,9 @@ private Object deserializeInternal(byte[] array) { } public byte[] serialize (T content) { - return serializeInternal(content); - } - - private byte[] serializeInternal(Object content) { try { objectOutput.resetForReUse(); - objectOutput.writeObject(content); + objectOutput.writeObject(content,type); return objectOutput.getCopyOfWrittenBuffer(); } catch (IOException e) { e.printStackTrace(); diff --git a/tpc/src/serializers/Hessian.java b/tpc/src/serializers/Hessian.java index b1455d3..d6707f2 100644 --- a/tpc/src/serializers/Hessian.java +++ b/tpc/src/serializers/Hessian.java @@ -11,7 +11,13 @@ public class Hessian { public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new HessianSerializer(MediaContent.class)); + groups.media.add(JavaBuiltIn.mediaTransformer, new HessianSerializer(MediaContent.class), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE,"" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/JBossMarshalling.java b/tpc/src/serializers/JBossMarshalling.java index a7318c5..99a1c32 100644 --- a/tpc/src/serializers/JBossMarshalling.java +++ b/tpc/src/serializers/JBossMarshalling.java @@ -40,8 +40,14 @@ public static void register(final TestGroups groups) { riverFactory, false, false - ) - ); + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "full graph zero knowledge" + ) + ); groups.media.add( JavaBuiltIn.mediaTransformer, new MarshallingSerializer( @@ -50,8 +56,14 @@ public static void register(final TestGroups groups) { riverFactory, false, true - ) - ); + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "full graph with manual optimizations" + ) + ); groups.media.add( JavaBuiltIn.mediaTransformer, new MarshallingSerializer( @@ -60,7 +72,13 @@ public static void register(final TestGroups groups) { riverFactory, true, false - ) + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "full graph with preregistered classes" + ) ); groups.media.add( JavaBuiltIn.mediaTransformer, @@ -70,7 +88,13 @@ public static void register(final TestGroups groups) { riverFactory, true, true - ) + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "full graph preregistered classes, manual optimization" + ) ); groups.media.add( JavaBuiltIn.mediaTransformer, @@ -80,7 +104,13 @@ public static void register(final TestGroups groups) { new SerialMarshallerFactory(), false, false - ) + ), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) ); } diff --git a/tpc/src/serializers/JBossSerialization.java b/tpc/src/serializers/JBossSerialization.java index 4c5c7fd..bd2c47f 100644 --- a/tpc/src/serializers/JBossSerialization.java +++ b/tpc/src/serializers/JBossSerialization.java @@ -19,7 +19,14 @@ public static void register(final TestGroups groups) { groups.media.add( JavaBuiltIn.mediaTransformer, new JBossSerializationSerializer(MediaContent.class) - ); + , + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } private static final class JBossSerializationSerializer diff --git a/tpc/src/serializers/JavaBuiltIn.java b/tpc/src/serializers/JavaBuiltIn.java index b9a703d..59ff189 100644 --- a/tpc/src/serializers/JavaBuiltIn.java +++ b/tpc/src/serializers/JavaBuiltIn.java @@ -17,8 +17,22 @@ public class JavaBuiltIn { public static void register(TestGroups groups) { - groups.media.add(mediaTransformer, new GenericSerializer("java-built-in",true)); - groups.media.add(mediaTransformer, new GenericSerializer("java-built-in-serializer",false)); + groups.media.add(mediaTransformer, new GenericSerializer("java-built-in",true), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); + groups.media.add(mediaTransformer, new GenericSerializer("java-built-in-serializer",false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/JavaManual.java b/tpc/src/serializers/JavaManual.java index 5fde8b4..2cec3e4 100644 --- a/tpc/src/serializers/JavaManual.java +++ b/tpc/src/serializers/JavaManual.java @@ -14,7 +14,14 @@ public final class JavaManual { public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new MediaContentSerializer()); + groups.media.add(JavaBuiltIn.mediaTransformer, new MediaContentSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/Kryo.java b/tpc/src/serializers/Kryo.java index 571c3cb..2ca601c 100644 --- a/tpc/src/serializers/Kryo.java +++ b/tpc/src/serializers/Kryo.java @@ -25,37 +25,77 @@ public static void register (TestGroups groups) { } private static void register (TestGroup group, Transformer transformer, TypeHandler handler) { - group.add(transformer, new DefaultSerializer()); - group.add(transformer, new BasicSerializer(handler)); - group.add(transformer, new OptimizedSerializer(handler)); - group.add(transformer, new CustomSerializer(handler)); + group.add(transformer, new DefaultSerializer(handler, true), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "default" + ) + ); + group.add(transformer, new DefaultSerializer(handler, false), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "default, no shared refs" + ) + ); + group.add(transformer, new BasicSerializer(handler), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "no shared refs, preregistered classes" + ) + ); + group.add(transformer, new OptimizedSerializer(handler), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "manually optimized" + ) + ); + group.add(transformer, new CustomSerializer(handler), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "manually optimized" + ) + ); } // ------------------------------------------------------------ // Serializers - /** This is the most basic Kryo usage. Just register the classes and go. */ + /** This is the most basic Kryo usage. Don't register anything go. */ public static class DefaultSerializer extends Serializer { final com.esotericsoftware.kryo.Kryo kryo; private final byte[] buffer = new byte[BUFFER_SIZE]; private final Output output = new Output(buffer, -1); private final Input input = new Input(buffer); + private final Class type; + boolean shared; - public DefaultSerializer () { + public DefaultSerializer (TypeHandler handler,boolean shared) { + this.type = handler.type; + this.shared = shared; this.kryo = new com.esotericsoftware.kryo.Kryo(); - kryo.setReferences(true); + kryo.setReferences(shared); kryo.setRegistrationRequired(false); } @SuppressWarnings("unchecked") public T deserialize (byte[] array) { input.setBuffer(array); - return (T) kryo.readClassAndObject(input); + return (T) kryo.readObject(input, type); } public byte[] serialize (T content) { output.setBuffer(buffer, -1); - kryo.writeClassAndObject(output, content); + kryo.writeObject(output, content); return output.toBytes(); } @@ -78,11 +118,11 @@ public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOE } public String getName () { - return "kryo-serializer"; + return "kryo"+(shared?"-serializer":"-flat"); } } - /** This is the most basic Kryo usage. Just register the classes and go. */ + /** This is slightly advanced Kryo usage. Just register the classes and go. */ public static class BasicSerializer extends Serializer { private final Class type; final com.esotericsoftware.kryo.Kryo kryo; @@ -128,7 +168,7 @@ public T[] deserializeItems (InputStream inStream, int numberOfItems) throws IOE } public String getName () { - return "kryo"; + return "kryo-flat-pre"; } } diff --git a/tpc/src/serializers/MiscFeatures.java b/tpc/src/serializers/MiscFeatures.java new file mode 100644 index 0000000..b8bd1f3 --- /dev/null +++ b/tpc/src/serializers/MiscFeatures.java @@ -0,0 +1,35 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 11.03.14 + * Time: 19:48 + * To change this template use File | Settings | File Templates. + */ + +/** + * describes misc miscFeatures a serializer might have. + */ +public enum MiscFeatures { + VERSIONING_BACKWARD_COMPATIBLE, + VERSIONING_FORWARD_COMPATIBLE, + VERSIONING_MISMATCH_DETECTION, + CONTAINS_SCHEMA, + OPTIMIZATION_BY_ANNOTATION +} diff --git a/tpc/src/serializers/MongoDB.java b/tpc/src/serializers/MongoDB.java index 770f5cf..190d332 100644 --- a/tpc/src/serializers/MongoDB.java +++ b/tpc/src/serializers/MongoDB.java @@ -19,7 +19,14 @@ public class MongoDB { public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new MongoDBSerializer()); + groups.media.add(JavaBuiltIn.mediaTransformer, new MongoDBSerializer(), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } public static final class MongoDBSerializer extends Serializer diff --git a/tpc/src/serializers/Obser.java b/tpc/src/serializers/Obser.java index 5e15ec3..9650df6 100644 --- a/tpc/src/serializers/Obser.java +++ b/tpc/src/serializers/Obser.java @@ -21,10 +21,38 @@ public static void register (TestGroups groups) { } private static void register (TestGroup group, Transformer transformer) { - group.add(transformer, new BasicSerializer()); - group.add(transformer, new CompactSerializer()); - group.add(transformer, new CustomSerializer()); - group.add(transformer, new CustomCompactSerializer()); + group.add(transformer, new BasicSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + group.add(transformer, new CompactSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.CLASSES_KNOWN, + "" + ) + ); + group.add(transformer, new CustomSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "" + ) + ); + group.add(transformer, new CustomCompactSerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FULL_GRAPH, + SerClass.MANUAL_OPT, + "" + ) + ); } diff --git a/tpc/src/serializers/SerClass.java b/tpc/src/serializers/SerClass.java new file mode 100644 index 0000000..430ef6a --- /dev/null +++ b/tpc/src/serializers/SerClass.java @@ -0,0 +1,43 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:31 + * To change this template use File | Settings | File Templates. + */ +public enum SerClass { + /** + * nothing must be known in advance or language built-in (e.g. JDK Serializable) + */ + ZERO_KNOWLEDGE, + /** + * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required + */ + CLASSES_KNOWN, + /** + * requires knowledge in advance which classes can be serialized. Preconfiguration/Code Generation required + * additionally field specific manually written read/write code + */ + MANUAL_OPT, + /** + * add new category if you fall into this :-) + */ + MISC +} diff --git a/tpc/src/serializers/SerFeatures.java b/tpc/src/serializers/SerFeatures.java new file mode 100644 index 0000000..e598c86 --- /dev/null +++ b/tpc/src/serializers/SerFeatures.java @@ -0,0 +1,113 @@ +package serializers; + +import java.util.EnumSet; +import java.util.Formatter; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:41 + * To change this template use File | Settings | File Templates. + */ +public class SerFeatures { + SerFormat format = SerFormat.MISC; + SerGraph graph = SerGraph.UNKNOWN; + SerClass clz = SerClass.MISC; + // FIXME: should have used one EnumSet from the beginning so we could get rid of + // SerFormat,SerGraph,SerClass .. sigh. Too lazy to change this now :-). ruediger + EnumSet miscFeatures = EnumSet.noneOf(MiscFeatures.class); + String description; + + public SerFeatures() { + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz) { + this.format = format; + this.graph = graph; + this.clz = clz; + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description) { + this.format = format; + this.graph = graph; + this.clz = clz; + this.description = description; + } + + public SerFeatures(SerFormat format, SerGraph graph, SerClass clz, String description, EnumSet features) { + this.format = format; + this.graph = graph; + this.clz = clz; + this.miscFeatures = features; + this.description = description; + } + + public EnumSet getMiscFeatures() { + return miscFeatures; + } + + public void setMiscFeatures(EnumSet miscFeatures) { + this.miscFeatures = miscFeatures; + } + + public String toString(String name) { + Formatter format = new Formatter().format( + "%-34s %-15s %-14s %-10s %-60s", + name, + getClz(), + getFormat(), + getGraph(), + getMiscFeatures()+" "+getDescription() + ); + return format.toString(); + } + + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + public SerFormat getFormat() { + return format; + } + + public void setFormat(SerFormat format) { + this.format = format; + } + + public SerGraph getGraph() { + return graph; + } + + public void setGraph(SerGraph graph) { + this.graph = graph; + } + + public SerClass getClz() { + return clz; + } + + public void setClz(SerClass clz) { + this.clz = clz; + } +} diff --git a/tpc/src/serializers/SerFormat.java b/tpc/src/serializers/SerFormat.java new file mode 100644 index 0000000..f5a3b31 --- /dev/null +++ b/tpc/src/serializers/SerFormat.java @@ -0,0 +1,46 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:29 + */ +public enum SerFormat { + /** + * unspecified binary format (e.g. JDK serialization) + */ + BINARY, + /** + * specified binary format which might be read by another language/implementation + */ + BIN_CROSSLANG, + /** + * text based JSon format + */ + JSON, + /** + * text based XML format + */ + XML, + /** + * none of the above + */ + MISC +} + diff --git a/tpc/src/serializers/SerGraph.java b/tpc/src/serializers/SerGraph.java new file mode 100644 index 0000000..0cb0a65 --- /dev/null +++ b/tpc/src/serializers/SerGraph.java @@ -0,0 +1,35 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 09.03.14 + * Time: 11:36 + * To change this template use File | Settings | File Templates. + */ +public enum SerGraph { + /** + * cannot process object graphs containing cyclic references (flat tree only) + */ + FLAT_TREE, + /** + * capable of read/write fully linked object graphs with reference restauration + */ + FULL_GRAPH, + UNKNOWN +} diff --git a/tpc/src/serializers/Serializer.java b/tpc/src/serializers/Serializer.java index be3e99d..96f4781 100644 --- a/tpc/src/serializers/Serializer.java +++ b/tpc/src/serializers/Serializer.java @@ -14,12 +14,22 @@ public abstract class Serializer public abstract S deserialize(byte[] array) throws Exception; public abstract byte[] serialize(S content) throws Exception; public abstract String getName(); - + + SerFeatures features = new SerFeatures(); // ruediger: everything misc by default. + public ByteArrayOutputStream outputStream (S content) { return new ByteArrayOutputStream(BUFFER_SIZE); } - // And then bit bigger default when serializing a list or array + public SerFeatures getFeatures() { + return features; + } + + public void setFeatures(SerFeatures features) { + this.features = features; + } + + // And then bit bigger default when serializing a list or array public ByteArrayOutputStream outputStreamForList (S[] items) { return new ByteArrayOutputStream(BUFFER_SIZE * items.length); } diff --git a/tpc/src/serializers/StatsCruncher.java b/tpc/src/serializers/StatsCruncher.java new file mode 100644 index 0000000..0d83bd3 --- /dev/null +++ b/tpc/src/serializers/StatsCruncher.java @@ -0,0 +1,513 @@ +package serializers; + +/** + * Copyright (c) 2012, Ruediger Moeller. All rights reserved. + *

+ * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + *

+ * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + *

+ * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301 USA + *

+ * Date: 08.03.14 + * Time: 22:08 + * To change this template use File | Settings | File Templates. + */ + +import java.io.*; +import java.lang.reflect.Field; +import java.net.URISyntaxException; +import java.net.URLEncoder; +import java.util.*; + +/** + * smallish program to read in the stats created by isolated runs (see new runscripts) + *

+ * 1. run-script runs each test in an isolated VM + * 2. the stats script collects result to stats.txt and runs this class to produce various charts from the bench data + *

+ * this helps in filtering out outliers / modify charts without having to run the tests + *

+ * assumes to be run in the same working dir as the bash run script + */ +public class StatsCruncher { + + public static final int MAX_CHART_BARS = 18; + HashMap mappedFeatures = new HashMap<>(); + HashMap mappedResults; + List resultList; + + static SerFormat BIN = SerFormat.BINARY; + static SerFormat BIN_CL = SerFormat.BIN_CROSSLANG; + static SerFormat JSON = SerFormat.JSON; + static SerFormat XML = SerFormat.XML; + static SerFormat MISC = SerFormat.MISC; + + public StatsCruncher() { + mappedFeatures = new BenchMarkExporter().getFeatureMap(); + } + + // ruediger: funny i am falling back to old school text parsing with +20 serializers on board ;-) + void readStats() throws IOException { + FileInputStream in = new FileInputStream("./stats.txt"); + BufferedReader din = new BufferedReader(new InputStreamReader(in)); + + mappedResults = new HashMap<>(); + resultList = new ArrayList<>(); + + String line; + while ((line = din.readLine()) != null) { + String split[] = line.split("\\s+"); + if (split == null || split.length < 2) + continue; + String testCase = split[0].trim(); + if ( split[1].trim().length() == 0 || !Character.isDigit(split[1].trim().charAt(0))) { + continue; + } + TestCaseResult res = new TestCaseResult(); + res.setName(split[0].trim()); + res.setCreate(Integer.parseInt(split[1].trim())); + res.setSer(Integer.parseInt(split[2].trim())); + res.setDeser(Integer.parseInt(split[3].trim())); + res.setTotal(Integer.parseInt(split[4].trim())); + res.setSize(Integer.parseInt(split[5].trim())); + res.setCompressedSize(Integer.parseInt(split[6].trim())); + mappedResults.put(res.getName(), res); + res.setFeatures(mappedFeatures.get(res.getName())); + resultList.add(res); + } + } + + public int max(List resultList, String arg, int elems) { + int max = Integer.MIN_VALUE; + for (int i = 0; i < Math.min(elems,resultList.size()); i++) { + TestCaseResult testCaseResult = resultList.get(i); + max = Math.max(testCaseResult.getInt(arg),max); + } + return max; + } + + public int min(List resultList, String arg) { + int min = Integer.MAX_VALUE; + for (int i = 0; i < resultList.size(); i++) { + TestCaseResult testCaseResult = resultList.get(i); + min = Math.min(testCaseResult.getInt(arg),min); + } + return min; + } + + public String generateChart(List resultList, String title, String lowerValueName, String higherValueName) { + int chartSize = Math.min(MAX_CHART_BARS, resultList.size() ); // more bars aren't possible with gcharts + int max = max(resultList, higherValueName, MAX_CHART_BARS); + String res = "https://chart.googleapis.com/chart?cht=bhs&chs=600x"+(chartSize *20+14); // html: finally a device independent technology +// res+="&chtt="+URLEncoder.encode(title); + res+="&chd=t:"; + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(i); + int val = testCaseResult.getInt(lowerValueName); + res+= val +((i< chartSize -1) ? ",":"|"); + } + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(i); + int valLower = (testCaseResult.getInt(lowerValueName)); + int val = testCaseResult.getInt(higherValueName); + val -= valLower; + res+=val+((i< chartSize -1) ? ",":""); + } + res += "&chco=5d99f9,4d89f9"; + res += "&chdlp=t"; + res += "&chbh=15"; + res += "&chds=0,"+max; + res += "&chxr=1,0,"+max; + res += "&chxt=y,x&chxl=0:|"; + for (int i = 0; i < chartSize; i++) { + TestCaseResult testCaseResult = resultList.get(chartSize -i-1); + res+=URLEncoder.encode(testCaseResult.getName())+((i< chartSize -1) ? "|":""); + } + return ""+title+"
"; + } + + /** + * + * @param commaSeparatedNames - * for all + * @param intFieldToSort - result field name to sort for (create ser deser total size compressedSize) + * @param maxRangeDiff - max distance of min value (remove outliers) + * @param maxListLen - max number of entries in result + * @return + */ + public List generateChartList(String commaSeparatedNames, final String intFieldToSort, int maxRangeDiff, int maxListLen, SerFeatures featureFilter) + { + String toChart[] = commaSeparatedNames.split(","); + List chartList = new ArrayList<>(); + if ( commaSeparatedNames.equals("*") ) { + chartList.addAll(resultList); + } else { + for (int i = 0; i < toChart.length; i++) { + toChart[i] = toChart[i].trim(); + TestCaseResult res = mappedResults.get(toChart[i]); + if ( res == null ) { + System.out.println("Cannot chart "+toChart[i]+" (not found in stats)"); + } else { + chartList.add(res); + } + } + } + chartList = sort(intFieldToSort, chartList); + // process feature filter (I am in dirt mode here ..) + for (int i = 0; i < chartList.size(); i++) { + TestCaseResult testCaseResult = chartList.get(i); + SerFeatures feature = testCaseResult.getFeatures(); + if ( feature != null ) { + if ( + ( featureFilter.getClz() != null && ! featureFilter.getClz().equals(feature.getClz()) ) || + ( featureFilter.getFormat() != null && ! featureFilter.getFormat().equals(feature.getFormat()) ) || + ( featureFilter.getGraph() != null && ! featureFilter.getGraph().equals(feature.getGraph()) ) + ) + { + chartList.remove(i--); + } + } else { + System.out.println("feature is unexpectedly null for "+testCaseResult.getName()); + chartList.remove(i--); + } + } + + // process rangeDiff and maxLen + int min = min(chartList,intFieldToSort); + for (int i = 0; i < chartList.size(); i++) { + TestCaseResult testCaseResult = chartList.get(i); + if ( min * maxRangeDiff < testCaseResult.getInt(intFieldToSort) || i >= maxListLen ) + chartList.remove(i--); + } + return chartList; + } + + protected List sort(final String intFieldToSort, List chartList) { + List res = new ArrayList<>(chartList); + Collections.sort(res, new Comparator() { + @Override + public int compare(TestCaseResult o1, TestCaseResult o2) { + return o1.getInt(intFieldToSort) - o2.getInt(intFieldToSort); + } + }); + return res; + } + + String dump(List total) { + String res = "\npre. create ser deser total size +dfl\n"; + for (int i = 0; i < total.size(); i++) { + TestCaseResult testCaseResult = total.get(i); + res+=testCaseResult.toString()+"\n"; + } + return res+"\n"; + } + + String dumpFeatures(List total) { + String res = "\npre. Effort Format Structure Misc\n"; + for (int i = 0; i < total.size(); i++) { + TestCaseResult testCaseResult = total.get(i); + res+=testCaseResult.getFeatures().toString(testCaseResult.getName())+"\n"; + } + return res+"\n"; + } + + String generateResultSection(List testCaseResults, String title, String desc) { + return "\n\n

"+title+"

\n"+desc+"\n"+ + generateChart(testCaseResults,"Ser Time+Deser Time (ns)","ser","total")+"\n"+ + generateChart( sort("size",testCaseResults),"Size, Compressed [light] in bytes","compressedSize","size")+"\n"+ + dump(testCaseResults); + } + + ////////////////////////////////////////////////////////////////////////////////// + + + // i just keep everything in code .. configfiles would add additional complexity and a query language .. + // the report is built to be displayed with Textile + public static void main(String arg[]) throws IOException, URISyntaxException { + StatsCruncher statsCruncher = new StatsCruncher(); + statsCruncher.readStats(); + + + +// PrintStream out = System.out; + PrintStream out = new PrintStream(new FileOutputStream("report.textile")); + + out.println("Test Platform"); + out.println("OS:"+System.getProperty("os.name")); + out.println("JVM:"+System.getProperty("java.vendor")+" "+System.getProperty("java.version")); + out.println("CPU:"+System.getenv("PROCESSOR_IDENTIFIER")+" os-arch:"+System.getenv("PROCESSOR_ARCHITECTURE")); + out.println("Cores (incl HT):"+Runtime.getRuntime().availableProcessors()); + out.println(); + + out.println("Disclamer\n" + + "\n" + + "This test focusses on en/decoding of a cyclefree data structure, but the featureset of the libraries compared differs a lot:\n" + + "* some serializers support cycle detection/object sharing others just write non-cyclic tree structures\n" + + "* some include full metadata in serialized output, some don't \n" + + "* some are cross platform, some are language specific \n" + + "* some are text based, some are binary, \n" + + "* some support versioning forward/backward, both, some don't \n\n" + + "(See \"ToolBehavior\":wiki/ToolBehavior)\n" + + "Other test data will yield different results (e.g. adding a non ascii char to every string :-) ). However the results give a raw estimation of library performance." + ); + + // first chart (like in previous tests) + // fastest of flat serializers (with or without preparation, exclude manually optimized) + List all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getGraph() == SerGraph.FULL_GRAPH // exclude full serializers + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",kryo-flat,fst-flat,protobuf/protostuff,protostuff-runtime,protobuf/protostuff-runtime," + .indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + String desc = "Benchmarks serializers \n" + + "* Only cycle free tree structures. An object referenced twice will be serialized twice. \n" + + "* no manual optimizations. \n" + + "* schema is known in advance (pre registration or even class generation). (Not all might make use of that) \n"; + out.println( statsCruncher.generateResultSection(all, "Serializers (no shared refs)", desc ) ); + + + // Second chart + // plain vanilla Full Graph serializers without generation/preparation + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getGraph() != SerGraph.FULL_GRAPH // exclude full serializers + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + + desc = + "Contains serializer(-configurations) \n"+ + "* supporting full object graph write/read. Object graph may contain cycles. If an Object is referenced twice, it will be so after deserialization.\n"+ + "* nothing is known in advance, no class generation, no preregistering of classes. Everything is captured at runtime using e.g. reflection.\n"+ + "* note this usually cannot be used cross language, however JSON/XML formats may enable cross language deserialization.\n" + ; + out.println( statsCruncher.generateResultSection(all, "Full Object Graph Serializers",desc) ); + + // 3rd chart + // Cross language binary serializer + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getFormat() != SerFormat.BIN_CROSSLANG + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) { + all.remove(i--); + } + } + desc = + "Contains serializer(-configurations) \n"+ + "* Only cycle free tree structures. An object referenced twice will be serialized twice. \n" + + "* schema is known in advance (pre registration, intermediate message description languages, class generation).\n" + ; + out.println( statsCruncher.generateResultSection(all, "Cross Lang Binary Serializers", desc) ); + + // 4th chart + // JSon+XML + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + (testCaseResult.getFeatures().getFormat() != SerFormat.JSON + && testCaseResult.getFeatures().getFormat() != SerFormat.XML) + || testCaseResult.getFeatures().getClz() == SerClass.MANUAL_OPT // exclude manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) + { + all.remove(i--); + } + } + desc = + "* text format based. Usually can be read by anybody. Frequently inline schema inside data.\n"+ + "* Mixed regarding required preparation, object graph awareness (references). \n" + ; + out.println( statsCruncher.generateResultSection(all, "XML/JSon Serializers", desc) ); + + // Manually optimized + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + testCaseResult.getFeatures().getClz() != SerClass.MANUAL_OPT // exclude NON manually optimized + || ",,".indexOf(","+testCaseResult.getName()+",") >= 0 // prevent some libs to contribute twice to chart + ) + { + all.remove(i--); + } + } + + desc = "all flavours of manually optimized serializers. Handcoded and hardwired to exactly the benchmark's message structures.\n"+ + "* illustrates what's possible, at what level generic approaches can be optimized in case\n"; + + out.println( statsCruncher.generateResultSection(all, "Manually optimized Serializers", desc) ); + + // Cost of miscFeatures + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + for (int i = 0; i < all.size(); i++) { + TestCaseResult testCaseResult = all.get(i); + if ( + ",fst,fst-flat,fst-flat-pre,kryo-manual,kryo-serializer,kryo-flat,kryo-flat-pre,protostuff,protostuff-runtime,protostuf-manual,msgpack-databind,msgpack-manual," + .indexOf(","+testCaseResult.getName()+",") < 0 // only these + ) + { + all.remove(i--); + } + } + desc = "shows performance vs convenience of manually-selected libs.\n"+ + "* cycle free, schema known at compile time, manual optimization: kryo-manual, msgpack-manual\n"+ + "* cycle free, schema known at compile time: protostuff, fst-flat-pre, kryo-flat-pre. (note: protostuff uses class generation while the other two just require a list of classes to be written) \n" + + "* cycle free, schema UNKNOWN at compile time: fst-flat, kryo-flat, protostuff-runtime, msgpack-databind \n"+ + "* full object graph awareness, schema UNKNOWN at compile time: fst, kryo.\n"; + out.println( statsCruncher.generateResultSection(all, "Cost of features",desc) ); + + all = statsCruncher.generateChartList("*", "total", 1000, 1000, new SerFeatures(null, null, null)); + out.println("

Full data

"); + out.println(statsCruncher.dump(all)); + out.println(); + out.println(statsCruncher.dumpFeatures(all)); + + + out.flush(); + } + + + + ////////////////////////////////////////////////////////////////////////////////// + + static class TestCaseResult { + String name; + int create; + int ser; + int deser; + int total; + int size; + int compressedSize; + SerFeatures features = new SerFeatures(); + + TestCaseResult() { + } + + TestCaseResult(String name, int create, int ser, int deser, int total, int size, int compressedSize) { + this.name = name; + this.create = create; + this.ser = ser; + this.deser = deser; + this.total = total; + this.size = size; + this.compressedSize = compressedSize; + } + + public SerFeatures getFeatures() { + return features; + } + + public void setFeatures(SerFeatures features) { + this.features = features; + } + + public int getInt(String name) { + try { + final Field f = TestCaseResult.class.getDeclaredField(name); + f.setAccessible(true); + return f.getInt(this); + } catch (IllegalAccessException e) { + e.printStackTrace(); + } catch (NoSuchFieldException e) { + e.printStackTrace(); + } + return 0; + } + + public String toString() { + Formatter format = new Formatter().format( + "%-34s %6d %7d %7d %7d %6d %5d", + name, + create, + ser, + deser, + total, + size, + compressedSize); + return format.toString(); + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public int getCreate() { + return create; + } + + public void setCreate(int create) { + this.create = create; + } + + public int getSer() { + return ser; + } + + public void setSer(int ser) { + this.ser = ser; + } + + public int getDeser() { + return deser; + } + + public void setDeser(int deser) { + this.deser = deser; + } + + public int getTotal() { + return total; + } + + public void setTotal(int total) { + this.total = total; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public int getCompressedSize() { + return compressedSize; + } + + public void setCompressedSize(int compressedSize) { + this.compressedSize = compressedSize; + } + + } + +} diff --git a/tpc/src/serializers/TestCaseRunner.java b/tpc/src/serializers/TestCaseRunner.java index bda0337..47ff705 100644 --- a/tpc/src/serializers/TestCaseRunner.java +++ b/tpc/src/serializers/TestCaseRunner.java @@ -1,7 +1,11 @@ package serializers; +import java.util.Arrays; + public final class TestCaseRunner { + static double measurementVals[] = new double[1000*1000]; + // because full gc is triggered by main loop, this should move to oldgen private final Transformer transformer; private final Serializer serializer; private final J value; @@ -18,13 +22,44 @@ public double run(TestCase tc, int iterations) throws Exception return tc.run(transformer, serializer, value, iterations); } - public double runTakeMin(int trials, TestCase tc, int iterations) throws Exception + public double runWithTimeMeasurement(int timeMillis, TestCase tc, int iterations) throws Exception { - double minTime = Double.MAX_VALUE; - for (int i = 0; i < trials; i++) { - double time = tc.run(transformer, serializer, value, iterations); - minTime = Math.min(minTime, time); - } - return minTime; + // ruediger: + // 1. made this also time based (like warmup). + // fast serializers get more exposure to hotspot and the slow ones will + // finish below 30 minute runtime :-). + // this is reasonable as the faster a serializer is, the more significant + // some few nanos become. A slow serializer being > 10seconds will not be biased + // by having some fewer loops. + // 2. taking the minimum time makes results very erratic. You get very different results + // with each run. Especially effects of bad allocation is hidden this way, as you only + // capture the "good" runs. + // therefore i switch to average measurement (and increase warmup time to avoid measurement of + // unjitted runs, see Params). + // We can do this when running each serializer isolated in an own VM. + long start = System.currentTimeMillis(); + + double sumTime = 0; + int count = 0; + System.err.println("test-time "+timeMillis+" iteration "+iterations); + while ( System.currentTimeMillis()-start < timeMillis ) + { + double time = tc.run(transformer, serializer, value, iterations); + sumTime += time; + measurementVals[count] = time; + count++; + } + double avg = sumTime / count; + Arrays.sort(measurementVals,0,count); + System.err.println("-----------------------------------------------------------------------------"); + System.err.println(serializer.getName()); + System.err.println("min:" + measurementVals[0]); + System.err.println("1/4:"+measurementVals[count/4]); + System.err.println("1/2:"+measurementVals[count/2]); + System.err.println("3/4:"+measurementVals[count/4*3]); + System.err.println("max:"+measurementVals[count-1]); + System.err.println("average:"+ avg +" deviation:"+(avg-measurementVals[count/2])); + System.err.println("-----------------------------------------------------------------------------"); + return avg; } } diff --git a/tpc/src/serializers/TestGroup.java b/tpc/src/serializers/TestGroup.java index 31c1792..7a043ff 100644 --- a/tpc/src/serializers/TestGroup.java +++ b/tpc/src/serializers/TestGroup.java @@ -9,15 +9,23 @@ public final class TestGroup { public final ArrayList> entries = new ArrayList>(); - private final Set entryNames = new HashSet(); + final Set entryNames = new HashSet(); public final Map> extensionMap = new HashMap>(); // So we know which one to use to load from files. + Map serMap= new HashMap<>(); - public void add(Transformer transformer, Serializer serializer) + public void add(Transformer transformer, Serializer serializer) + { + add(transformer,serializer,(SerFeatures)null); + } + + public void add(Transformer transformer, Serializer serializer, SerFeatures features) { + if ( features != null ) + serializer.setFeatures(features); add_(transformer, serializer); } - public void add(Transformer transformer, Serializer serializer, String extension) + public void add(Transformer transformer, Serializer serializer, String extension ) { Entry entry_ = add_(transformer, serializer); @@ -27,9 +35,14 @@ public void add(Transformer transformer, Serializer serializer, Stri } } - public Entry add_(Transformer transformer, Serializer serializer) + public Map getSerMap() { + return serMap; + } + + public Entry add_(Transformer transformer, Serializer serializer) { Entry entry = new Entry(transformer, serializer); + serMap.put(serializer.getName(),serializer); @SuppressWarnings("unchecked") Entry entry_ = (Entry) entry; diff --git a/tpc/src/serializers/Thrift.java b/tpc/src/serializers/Thrift.java index 380e449..16a4310 100644 --- a/tpc/src/serializers/Thrift.java +++ b/tpc/src/serializers/Thrift.java @@ -19,8 +19,22 @@ public class Thrift { public static void register(TestGroups groups) { - groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.DefaultBinary)); - groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.CompactBinary)); + groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.DefaultBinary), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); + groups.media.add(mediaTransformer, new MediaSerializer(ProtocolSpec.CompactBinary), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/Wobly.java b/tpc/src/serializers/Wobly.java index 15b1e15..61469c5 100644 --- a/tpc/src/serializers/Wobly.java +++ b/tpc/src/serializers/Wobly.java @@ -6,8 +6,22 @@ public class Wobly { public static void register(TestGroups groups) { - groups.media.add(new WoblySimpleUtils.WoblyTransformer(), new WoblySimpleUtils.WoblySerializer()); - groups.media.add(new WoblyCompactUtils.WoblyTransformer(), new WoblyCompactUtils.WoblySerializer()); + groups.media.add(new WoblySimpleUtils.WoblyTransformer(), new WoblySimpleUtils.WoblySerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); + groups.media.add(new WoblyCompactUtils.WoblyTransformer(), new WoblyCompactUtils.WoblySerializer(), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } } diff --git a/tpc/src/serializers/avro/AvroGeneric.java b/tpc/src/serializers/avro/AvroGeneric.java index 9386e59..c464b60 100644 --- a/tpc/src/serializers/avro/AvroGeneric.java +++ b/tpc/src/serializers/avro/AvroGeneric.java @@ -12,9 +12,7 @@ import org.apache.avro.io.BinaryEncoder; import org.apache.avro.io.BinaryDecoder; -import serializers.Serializer; -import serializers.TestGroups; -import serializers.Transformer; +import serializers.*; import java.io.ByteArrayOutputStream; import java.io.IOException; @@ -26,7 +24,14 @@ public class AvroGeneric { public static void register(TestGroups groups) { - groups.media.add(MediaTransformer, new GenericSerializer(Avro.Media.sMediaContent)); + groups.media.add(MediaTransformer, new GenericSerializer(Avro.Media.sMediaContent), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/avro/AvroSpecific.java b/tpc/src/serializers/avro/AvroSpecific.java index 2e1889f..e0c10c9 100644 --- a/tpc/src/serializers/avro/AvroSpecific.java +++ b/tpc/src/serializers/avro/AvroSpecific.java @@ -13,15 +13,21 @@ import org.apache.avro.specific.SpecificDatumReader; import org.apache.avro.specific.SpecificDatumWriter; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.avro.media.*; public class AvroSpecific { public static void register(TestGroups groups) { - groups.media.add(new AvroTransformer(), new GenericSerializer(MediaContent.class)); + groups.media.add(new AvroTransformer(), new GenericSerializer(MediaContent.class), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); } private static final DecoderFactory DECODER_FACTORY = DecoderFactory.get(); @@ -29,7 +35,7 @@ public static void register(TestGroups groups) public static final class GenericSerializer extends Serializer { - public String getName() { return "avro"; } + public String getName() { return "avro-specific"; } private final SpecificDatumReader READER; private final SpecificDatumWriter WRITER; diff --git a/tpc/src/serializers/cks/CksBinary.java b/tpc/src/serializers/cks/CksBinary.java index d58f688..c368c9f 100644 --- a/tpc/src/serializers/cks/CksBinary.java +++ b/tpc/src/serializers/cks/CksBinary.java @@ -3,15 +3,21 @@ import java.io.InputStream; import java.io.OutputStream; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.cks.media.MediaContent; public class CksBinary { public static void register(TestGroups groups) { - groups.media.add(Cks.mediaTransformer, MediaSerializer); + groups.media.add(Cks.mediaTransformer, MediaSerializer, + new SerFeatures( + SerFormat.MISC, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/jackson/JacksonAsArrayDatabind.java b/tpc/src/serializers/jackson/JacksonAsArrayDatabind.java index 07e1578..33f1310 100644 --- a/tpc/src/serializers/jackson/JacksonAsArrayDatabind.java +++ b/tpc/src/serializers/jackson/JacksonAsArrayDatabind.java @@ -1,7 +1,6 @@ package serializers.jackson; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import com.fasterxml.jackson.databind.*; @@ -19,12 +18,26 @@ public static void register(TestGroups groups) ObjectMapper jsonMapper = new ObjectMapper(); jsonMapper.setAnnotationIntrospector(new AsArrayIntrospector()); groups.media.add(JavaBuiltIn.mediaTransformer, - new StdJacksonDataBind("json/jackson-ARRAY/databind", MediaContent.class, jsonMapper)); + new StdJacksonDataBind("json/jackson-ARRAY/databind", MediaContent.class, jsonMapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); // and Smile one? ObjectMapper smileMapper = new ObjectMapper(new com.fasterxml.jackson.dataformat.smile.SmileFactory()); smileMapper.setAnnotationIntrospector(new AsArrayIntrospector()); groups.media.add(JavaBuiltIn.mediaTransformer, - new StdJacksonDataBind("smile/jackson-ARRAY/databind", MediaContent.class, smileMapper)); + new StdJacksonDataBind("smile/jackson-ARRAY/databind", MediaContent.class, smileMapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonAvroDatabind.java b/tpc/src/serializers/jackson/JacksonAvroDatabind.java index 10e2e90..0779686 100644 --- a/tpc/src/serializers/jackson/JacksonAvroDatabind.java +++ b/tpc/src/serializers/jackson/JacksonAvroDatabind.java @@ -1,7 +1,6 @@ package serializers.jackson; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import serializers.avro.Avro; import com.fasterxml.jackson.databind.JavaType; @@ -25,6 +24,13 @@ public static void register(TestGroups groups) ObjectReader reader = mapper.reader(type).with(schema); ObjectWriter writer = mapper.writerWithType(type).withSchema(schema); groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind - ("avro/jackson", type, mapper, reader, writer)); + ("avro/jackson", type, mapper, reader, writer), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonBsonDatabind.java b/tpc/src/serializers/jackson/JacksonBsonDatabind.java index 21cfb8f..8f5961a 100644 --- a/tpc/src/serializers/jackson/JacksonBsonDatabind.java +++ b/tpc/src/serializers/jackson/JacksonBsonDatabind.java @@ -9,9 +9,7 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import de.undercouch.bson4jackson.BsonFactory; import de.undercouch.bson4jackson.BsonModule; @@ -30,7 +28,14 @@ public static void register(TestGroups groups) mapper.registerModule(new BsonModule()); groups.media.add(JavaBuiltIn.mediaTransformer, new DataBindBase( - "bson/jackson/databind", MediaContent.class, mapper)); + "bson/jackson/databind", MediaContent.class, mapper), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } // Must bundle, because BSON module still uses Jackson 1.x... diff --git a/tpc/src/serializers/jackson/JacksonJsonAfterburner.java b/tpc/src/serializers/jackson/JacksonJsonAfterburner.java index 5ba9584..5aef7cb 100644 --- a/tpc/src/serializers/jackson/JacksonJsonAfterburner.java +++ b/tpc/src/serializers/jackson/JacksonJsonAfterburner.java @@ -4,8 +4,7 @@ import com.fasterxml.jackson.module.afterburner.AfterburnerModule; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; public class JacksonJsonAfterburner @@ -19,6 +18,13 @@ public static void register(TestGroups groups) mapper.registerModule(new AfterburnerModule()); groups.media.add(JavaBuiltIn.mediaTransformer, - new StdJacksonDataBind("json/jackson/db-afterburner", MediaContent.class, mapper)); + new StdJacksonDataBind("json/jackson/db-afterburner", MediaContent.class, mapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "uses bytecode generation to reduce overhead" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonJsonDatabind.java b/tpc/src/serializers/jackson/JacksonJsonDatabind.java index 8d50761..6523e74 100644 --- a/tpc/src/serializers/jackson/JacksonJsonDatabind.java +++ b/tpc/src/serializers/jackson/JacksonJsonDatabind.java @@ -1,8 +1,7 @@ package serializers.jackson; import data.media.MediaContent; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import com.fasterxml.jackson.databind.*; @@ -18,6 +17,13 @@ public static void register(TestGroups groups) ObjectMapper mapper = new ObjectMapper(); // note: could also force static typing; left out to keep defaults groups.media.add(JavaBuiltIn.mediaTransformer, - new StdJacksonDataBind("json/jackson/databind", MediaContent.class, mapper)); + new StdJacksonDataBind("json/jackson/databind", MediaContent.class, mapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonJsonDatabindWithStrings.java b/tpc/src/serializers/jackson/JacksonJsonDatabindWithStrings.java index 945e2e1..27fe131 100644 --- a/tpc/src/serializers/jackson/JacksonJsonDatabindWithStrings.java +++ b/tpc/src/serializers/jackson/JacksonJsonDatabindWithStrings.java @@ -7,8 +7,7 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.databind.*; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; /** * This serializer uses Jackson in full automated data binding mode, which @@ -20,7 +19,14 @@ public class JacksonJsonDatabindWithStrings extends BaseJacksonDataBind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new JacksonJsonDatabindWithStrings(MediaContent.class)); + new JacksonJsonDatabindWithStrings(MediaContent.class), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } public JacksonJsonDatabindWithStrings(Class clz) { diff --git a/tpc/src/serializers/jackson/JacksonJsonManual.java b/tpc/src/serializers/jackson/JacksonJsonManual.java index 64e1638..b95d23a 100644 --- a/tpc/src/serializers/jackson/JacksonJsonManual.java +++ b/tpc/src/serializers/jackson/JacksonJsonManual.java @@ -10,8 +10,7 @@ import com.fasterxml.jackson.core.*; import com.fasterxml.jackson.core.io.SerializedString; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; /** * "Hand-written" version of Jackson-based codec. Not optimized for compactness, @@ -38,7 +37,14 @@ public class JacksonJsonManual extends BaseJacksonDriver public static void register(TestGroups groups) { JsonFactory factory = new JsonFactory(); - groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("json/jackson/manual", factory)); + groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("json/jackson/manual", factory), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } private final JsonFactory _factory; diff --git a/tpc/src/serializers/jackson/JacksonJsonTree.java b/tpc/src/serializers/jackson/JacksonJsonTree.java index 5c127d9..83b5751 100644 --- a/tpc/src/serializers/jackson/JacksonJsonTree.java +++ b/tpc/src/serializers/jackson/JacksonJsonTree.java @@ -11,8 +11,7 @@ import com.fasterxml.jackson.databind.node.ArrayNode; import com.fasterxml.jackson.databind.node.ObjectNode; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.Media; @@ -26,7 +25,14 @@ public class JacksonJsonTree extends BaseJacksonDataBind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonTree( - "json/jackson/tree",new ObjectMapper())); + "json/jackson/tree",new ObjectMapper()), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } public JacksonJsonTree(String name, ObjectMapper mapper) { diff --git a/tpc/src/serializers/jackson/JacksonJsonTreeWithStrings.java b/tpc/src/serializers/jackson/JacksonJsonTreeWithStrings.java index 5dbdc8d..1ee62c1 100644 --- a/tpc/src/serializers/jackson/JacksonJsonTreeWithStrings.java +++ b/tpc/src/serializers/jackson/JacksonJsonTreeWithStrings.java @@ -5,8 +5,7 @@ import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.ObjectMapper; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -18,7 +17,14 @@ public class JacksonJsonTreeWithStrings extends JacksonJsonTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new JacksonJsonTreeWithStrings("json/jackson/tree-strings", new ObjectMapper())); + new JacksonJsonTreeWithStrings("json/jackson/tree-strings", new ObjectMapper()), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } public JacksonJsonTreeWithStrings(String name, ObjectMapper mapper) { diff --git a/tpc/src/serializers/jackson/JacksonSmileAfterburner.java b/tpc/src/serializers/jackson/JacksonSmileAfterburner.java index cbacea8..50c7895 100644 --- a/tpc/src/serializers/jackson/JacksonSmileAfterburner.java +++ b/tpc/src/serializers/jackson/JacksonSmileAfterburner.java @@ -5,8 +5,7 @@ import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.dataformat.smile.SmileGenerator; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import com.fasterxml.jackson.module.afterburner.AfterburnerModule; @@ -32,6 +31,13 @@ public static void register(TestGroups groups, boolean sharedNames, boolean shar smileMapper.registerModule(new AfterburnerModule()); groups.media.add(JavaBuiltIn.mediaTransformer, - new StdJacksonDataBind("smile/jackson/db-afterburner", MediaContent.class, smileMapper)); + new StdJacksonDataBind("smile/jackson/db-afterburner", MediaContent.class, smileMapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonSmileDatabind.java b/tpc/src/serializers/jackson/JacksonSmileDatabind.java index 9a6f686..29f50d8 100644 --- a/tpc/src/serializers/jackson/JacksonSmileDatabind.java +++ b/tpc/src/serializers/jackson/JacksonSmileDatabind.java @@ -5,8 +5,7 @@ import com.fasterxml.jackson.dataformat.smile.*; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -27,7 +26,14 @@ public static void register(TestGroups groups, boolean sharedNames, boolean shar groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind("smile/jackson/databind", - MediaContent.class, mapper)); + MediaContent.class, mapper), + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonSmileManual.java b/tpc/src/serializers/jackson/JacksonSmileManual.java index 8e90587..5575194 100644 --- a/tpc/src/serializers/jackson/JacksonSmileManual.java +++ b/tpc/src/serializers/jackson/JacksonSmileManual.java @@ -2,8 +2,7 @@ import com.fasterxml.jackson.dataformat.smile.*; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; public class JacksonSmileManual { @@ -16,7 +15,14 @@ public static void register(TestGroups groups, boolean sharedNames, boolean shar SmileFactory factory = new SmileFactory(); factory.configure(SmileGenerator.Feature.CHECK_SHARED_NAMES, sharedNames); factory.configure(SmileGenerator.Feature.CHECK_SHARED_STRING_VALUES, sharedValues); - groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("smile/jackson/manual", factory)); + groups.media.add(JavaBuiltIn.mediaTransformer, new JacksonJsonManual("smile/jackson/manual", factory), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonXmlDatabind.java b/tpc/src/serializers/jackson/JacksonXmlDatabind.java index cdb2890..03c36c0 100644 --- a/tpc/src/serializers/jackson/JacksonXmlDatabind.java +++ b/tpc/src/serializers/jackson/JacksonXmlDatabind.java @@ -1,7 +1,6 @@ package serializers.jackson; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import com.fasterxml.aalto.stax.InputFactoryImpl; import com.fasterxml.aalto.stax.OutputFactoryImpl; @@ -23,6 +22,13 @@ public static void register(TestGroups groups) new InputFactoryImpl(), new OutputFactoryImpl())); groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind("xml/jackson/databind-aalto", - MediaContent.class, mapper)); + MediaContent.class, mapper), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/jackson/JacksonYAMLDatabind.java b/tpc/src/serializers/jackson/JacksonYAMLDatabind.java index 90b42c8..6de02b4 100644 --- a/tpc/src/serializers/jackson/JacksonYAMLDatabind.java +++ b/tpc/src/serializers/jackson/JacksonYAMLDatabind.java @@ -3,8 +3,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -15,6 +14,13 @@ public static void register(TestGroups groups) ObjectMapper mapper = new ObjectMapper(new YAMLFactory()); groups.media.add(JavaBuiltIn.mediaTransformer, new StdJacksonDataBind("yaml/jackson", - MediaContent.class, mapper)); + MediaContent.class, mapper), + new SerFeatures( + SerFormat.JSON, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/javaxjson/JavaxJsonStreamGlassfish.java b/tpc/src/serializers/javaxjson/JavaxJsonStreamGlassfish.java index cfb1e44..6425d93 100644 --- a/tpc/src/serializers/javaxjson/JavaxJsonStreamGlassfish.java +++ b/tpc/src/serializers/javaxjson/JavaxJsonStreamGlassfish.java @@ -17,6 +17,13 @@ public String getName() { } public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new JavaxJsonStreamGlassfish()); + groups.media.add(JavaBuiltIn.mediaTransformer, new JavaxJsonStreamGlassfish(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } } diff --git a/tpc/src/serializers/javaxjson/JavaxJsonTreeGlassfish.java b/tpc/src/serializers/javaxjson/JavaxJsonTreeGlassfish.java index b0a6290..2cc3f53 100644 --- a/tpc/src/serializers/javaxjson/JavaxJsonTreeGlassfish.java +++ b/tpc/src/serializers/javaxjson/JavaxJsonTreeGlassfish.java @@ -17,6 +17,13 @@ public String getName() { } public static void register(TestGroups groups) { - groups.media.add(new JavaxJsonTransformer(JSON), new JavaxJsonTreeGlassfish()); + groups.media.add(new JavaxJsonTransformer(JSON), new JavaxJsonTreeGlassfish(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } } diff --git a/tpc/src/serializers/json/FastJSONDatabind.java b/tpc/src/serializers/json/FastJSONDatabind.java index b6fddc5..11f37e6 100644 --- a/tpc/src/serializers/json/FastJSONDatabind.java +++ b/tpc/src/serializers/json/FastJSONDatabind.java @@ -2,9 +2,7 @@ import java.io.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -20,7 +18,14 @@ public class FastJSONDatabind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new GenericSerializer("json/fastjson/databind", MediaContent.class)); + new GenericSerializer("json/fastjson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } static class GenericSerializer extends Serializer diff --git a/tpc/src/serializers/json/FlexjsonDatabind.java b/tpc/src/serializers/json/FlexjsonDatabind.java index bf5c884..cdada54 100644 --- a/tpc/src/serializers/json/FlexjsonDatabind.java +++ b/tpc/src/serializers/json/FlexjsonDatabind.java @@ -2,9 +2,7 @@ import java.io.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; import flexjson.JSONDeserializer; @@ -19,7 +17,14 @@ public class FlexjsonDatabind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new GenericSerializer("json/flexjson/databind", MediaContent.class)); + new GenericSerializer("json/flexjson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } static class GenericSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonArgoTree.java b/tpc/src/serializers/json/JsonArgoTree.java index 07901b1..05da9ac 100644 --- a/tpc/src/serializers/json/JsonArgoTree.java +++ b/tpc/src/serializers/json/JsonArgoTree.java @@ -15,9 +15,7 @@ import java.util.List; import java.util.Map; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import argo.format.CompactJsonFormatter; import argo.format.JsonFormatter; @@ -39,7 +37,14 @@ public class JsonArgoTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualTreeSerializer("json/argo-manual/tree")); + new ManualTreeSerializer("json/argo-manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class ManualTreeSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonDotOrgManualTree.java b/tpc/src/serializers/json/JsonDotOrgManualTree.java index 4221efa..c08a4fb 100644 --- a/tpc/src/serializers/json/JsonDotOrgManualTree.java +++ b/tpc/src/serializers/json/JsonDotOrgManualTree.java @@ -8,9 +8,7 @@ import org.json.JSONObject; import org.json.JSONWriter; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.Media; @@ -24,7 +22,14 @@ public class JsonDotOrgManualTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualTreeSerializer("json/org.json/manual/tree")); + new ManualTreeSerializer("json/org.json/manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class ManualTreeSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonGsonDatabind.java b/tpc/src/serializers/json/JsonGsonDatabind.java index 3591d90..bdc66e2 100644 --- a/tpc/src/serializers/json/JsonGsonDatabind.java +++ b/tpc/src/serializers/json/JsonGsonDatabind.java @@ -2,9 +2,7 @@ import java.io.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -17,7 +15,14 @@ public class JsonGsonDatabind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new GenericSerializer("json/google-gson/databind", MediaContent.class)); + new GenericSerializer("json/google-gson/databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/json/JsonGsonManual.java b/tpc/src/serializers/json/JsonGsonManual.java index bd2d27d..b3f264b 100644 --- a/tpc/src/serializers/json/JsonGsonManual.java +++ b/tpc/src/serializers/json/JsonGsonManual.java @@ -6,9 +6,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import com.google.gson.stream.*; @@ -25,7 +23,14 @@ public class JsonGsonManual public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualSerializer("json/google-gson/manual")); + new ManualSerializer("json/google-gson/manual"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/json/JsonGsonTree.java b/tpc/src/serializers/json/JsonGsonTree.java index 21d3e42..a5250fd 100644 --- a/tpc/src/serializers/json/JsonGsonTree.java +++ b/tpc/src/serializers/json/JsonGsonTree.java @@ -5,9 +5,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import com.google.gson.JsonArray; import com.google.gson.JsonElement; @@ -27,7 +25,14 @@ public class JsonGsonTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new SemiManualSerializer("json/google-gson/manual/tree")); + new SemiManualSerializer("json/google-gson/manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class SemiManualSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonLibJsonDatabind.java b/tpc/src/serializers/json/JsonLibJsonDatabind.java index cd71099..a4cbe66 100644 --- a/tpc/src/serializers/json/JsonLibJsonDatabind.java +++ b/tpc/src/serializers/json/JsonLibJsonDatabind.java @@ -4,9 +4,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.Media; @@ -20,7 +18,14 @@ public class JsonLibJsonDatabind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new GenericSerializer("json/json-lib-databind", MediaContent.class)); + new GenericSerializer("json/json-lib-databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } static class GenericSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonPathDeserializerOnly.java b/tpc/src/serializers/json/JsonPathDeserializerOnly.java index 5e7c897..616a82b 100644 --- a/tpc/src/serializers/json/JsonPathDeserializerOnly.java +++ b/tpc/src/serializers/json/JsonPathDeserializerOnly.java @@ -8,9 +8,7 @@ import org.json.simple.JSONArray; import org.json.simple.JSONObject; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import com.jayway.jsonpath.JsonPath; @@ -27,7 +25,14 @@ public class JsonPathDeserializerOnly public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new SemiManualSerializer("json/jsonpath/json.simple")); + new SemiManualSerializer("json/jsonpath/json.simple"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class SemiManualSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonSimpleManualTree.java b/tpc/src/serializers/json/JsonSimpleManualTree.java index 52824cf..bce4365 100644 --- a/tpc/src/serializers/json/JsonSimpleManualTree.java +++ b/tpc/src/serializers/json/JsonSimpleManualTree.java @@ -10,9 +10,7 @@ import org.json.simple.JSONObject; import org.json.simple.parser.JSONParser; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.Media; @@ -26,7 +24,15 @@ public class JsonSimpleManualTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualTreeSerializer("json/json.simple/manual/tree")); + new ManualTreeSerializer("json/json.simple/manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "fst in unshared mode with preregistered classes" + ) + ); + } static class ManualTreeSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonSimpleWithContentHandler.java b/tpc/src/serializers/json/JsonSimpleWithContentHandler.java index ac798c7..c785a09 100644 --- a/tpc/src/serializers/json/JsonSimpleWithContentHandler.java +++ b/tpc/src/serializers/json/JsonSimpleWithContentHandler.java @@ -12,9 +12,7 @@ import org.json.simple.parser.JSONParser; import org.json.simple.parser.ParseException; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.Media; @@ -28,7 +26,14 @@ public class JsonSimpleWithContentHandler public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new SemiManualSerializer("json/json.simple/manual")); + new SemiManualSerializer("json/json.simple/manual"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class SemiManualSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonSmartManualTree.java b/tpc/src/serializers/json/JsonSmartManualTree.java index 46a3e31..9b88ad7 100644 --- a/tpc/src/serializers/json/JsonSmartManualTree.java +++ b/tpc/src/serializers/json/JsonSmartManualTree.java @@ -6,9 +6,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import net.minidev.json.JSONArray; import net.minidev.json.JSONObject; @@ -26,7 +24,14 @@ public class JsonSmartManualTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualTreeSerializer("json/json-smart/manual/tree")); + new ManualTreeSerializer("json/json-smart/manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class ManualTreeSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonSvensonDatabind.java b/tpc/src/serializers/json/JsonSvensonDatabind.java index d3f850f..d8b4f84 100644 --- a/tpc/src/serializers/json/JsonSvensonDatabind.java +++ b/tpc/src/serializers/json/JsonSvensonDatabind.java @@ -2,9 +2,7 @@ import java.io.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.Image; import data.media.MediaContent; @@ -17,7 +15,14 @@ public class JsonSvensonDatabind public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new GenericSerializer("json/svenson-databind", MediaContent.class)); + new GenericSerializer("json/svenson-databind", MediaContent.class), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class GenericSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonijJpath.java b/tpc/src/serializers/json/JsonijJpath.java index 1564014..0d4aa5e 100644 --- a/tpc/src/serializers/json/JsonijJpath.java +++ b/tpc/src/serializers/json/JsonijJpath.java @@ -5,9 +5,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import jsonij.json.JPath; import jsonij.json.JSON; @@ -27,7 +25,14 @@ public class JsonijJpath public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new SemiManualSerializer("json/jsonij-jpath")); + new SemiManualSerializer("json/jsonij-jpath"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class SemiManualSerializer extends Serializer diff --git a/tpc/src/serializers/json/JsonijManualTree.java b/tpc/src/serializers/json/JsonijManualTree.java index 9fafe7e..18a03c6 100644 --- a/tpc/src/serializers/json/JsonijManualTree.java +++ b/tpc/src/serializers/json/JsonijManualTree.java @@ -5,9 +5,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import jsonij.json.JSON; import jsonij.json.JSONMarshaler; @@ -25,7 +23,14 @@ public class JsonijManualTree public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, - new ManualTreeSerializer("json/jsonij-manual/tree")); + new ManualTreeSerializer("json/jsonij-manual/tree"), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } static class ManualTreeSerializer extends Serializer diff --git a/tpc/src/serializers/msgpack/MsgPack.java b/tpc/src/serializers/msgpack/MsgPack.java index dbf1e57..47a4d13 100644 --- a/tpc/src/serializers/msgpack/MsgPack.java +++ b/tpc/src/serializers/msgpack/MsgPack.java @@ -2,10 +2,7 @@ import org.msgpack.MessagePack; -import serializers.JavaBuiltIn; -import serializers.TestGroup; -import serializers.TestGroups; -import serializers.Transformer; +import serializers.*; public class MsgPack { @@ -18,12 +15,26 @@ private static void register(TestGroup group, Transformer transfor MessagePack msgpack = new MessagePack(); TypeHandler h = (TypeHandler) new MediaContentTypeHandler(); h.register(msgpack); - group.add(transformer, new MsgPackSerializer("msgpack-databind", h, msgpack)); + group.add(transformer, new MsgPackSerializer("msgpack-databind", h, msgpack), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); msgpack = new MessagePack(); h = (TypeHandler) new MediaContentTypeHandler(); h.registerManually(msgpack); - group.add(transformer, new MsgPackSerializer("msgpack-manual", h, msgpack)); + group.add(transformer, new MsgPackSerializer("msgpack-manual", h, msgpack), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); } } \ No newline at end of file diff --git a/tpc/src/serializers/protobuf/ActiveMQProtobuf.java b/tpc/src/serializers/protobuf/ActiveMQProtobuf.java index 6e84262..8aa52ad 100644 --- a/tpc/src/serializers/protobuf/ActiveMQProtobuf.java +++ b/tpc/src/serializers/protobuf/ActiveMQProtobuf.java @@ -6,8 +6,7 @@ import data.media.MediaTransformer; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.activemq.media.MediaContentHolder.Image; import serializers.activemq.media.MediaContentHolder.Media; import serializers.activemq.media.MediaContentHolder.MediaContent; @@ -22,7 +21,14 @@ public class ActiveMQProtobuf { public static void register(TestGroups groups) { - groups.media.add(mediaTransformer, MediaSerializer); + groups.media.add(mediaTransformer, MediaSerializer, + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/protobuf/Protobuf.java b/tpc/src/serializers/protobuf/Protobuf.java index 7418544..d75edbf 100644 --- a/tpc/src/serializers/protobuf/Protobuf.java +++ b/tpc/src/serializers/protobuf/Protobuf.java @@ -9,8 +9,7 @@ import data.media.MediaTransformer; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; /** *

@@ -21,7 +20,14 @@ public class Protobuf { public static void register(TestGroups groups) { - groups.media.add(new Transformer(), new PBSerializer()); + groups.media.add(new Transformer(), new PBSerializer(), + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } // ------------------------------------------------------------ diff --git a/tpc/src/serializers/protobuf/ProtobufJson.java b/tpc/src/serializers/protobuf/ProtobufJson.java index 91514b8..dc2b36b 100644 --- a/tpc/src/serializers/protobuf/ProtobufJson.java +++ b/tpc/src/serializers/protobuf/ProtobufJson.java @@ -1,7 +1,6 @@ package serializers.protobuf; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.protobuf.media.MediaContentHolder.MediaContent; import java.io.IOException; @@ -12,7 +11,14 @@ public class ProtobufJson { public static void register(TestGroups groups) { - groups.media.add(new Protobuf.Transformer(), new JsonSerializer()); + groups.media.add(new Protobuf.Transformer(), new JsonSerializer(), + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); } private static final Charset _charset = Charset.forName("UTF-8"); diff --git a/tpc/src/serializers/protostuff/Protostuff.java b/tpc/src/serializers/protostuff/Protostuff.java index cd00cb9..56c515a 100644 --- a/tpc/src/serializers/protostuff/Protostuff.java +++ b/tpc/src/serializers/protostuff/Protostuff.java @@ -17,9 +17,7 @@ import data.media.MediaTransformer; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.protostuff.media.MediaContent; import serializers.protostuff.media.Media; import serializers.protostuff.media.Image; @@ -30,17 +28,54 @@ public final class Protostuff public static void register(TestGroups groups) { // generated code - groups.media.add(mediaTransformer, ProtostuffMediaSerializer); + groups.media.add(mediaTransformer, ProtostuffMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "generated code" + ) + ); // manual (hand-coded schema, no autoboxing) - groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffManualMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffManualMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); // runtime (reflection) - groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffRuntimeMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, ProtostuffRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "" + ) + ); // protobuf serialization + generated code - groups.media.add(mediaTransformer, ProtobufMediaSerializer); - + groups.media.add(mediaTransformer, ProtobufMediaSerializer, + new SerFeatures( + SerFormat.BIN_CROSSLANG, + SerGraph.FLAT_TREE, + SerClass.CLASSES_KNOWN, + "protobuf serialization + generated code" + ) + ); + + // protobuf serialization + runtime + groups.media.add(JavaBuiltIn.mediaTransformer, ProtobufRuntimeMediaSerializer, + new SerFeatures( + SerFormat.BINARY, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); /*protostuff has too many entries // graph+manual @@ -49,8 +84,7 @@ public static void register(TestGroups groups) // graph+runtime groups.media.add(JavaBuiltIn.MediaTransformer, ProtostuffGraphRuntimeMediaSerializer); - // protobuf serialization + runtime - groups.media.add(JavaBuiltIn.MediaTransformer, ProtobufRuntimeMediaSerializer);*/ +*/ } public static final Serializer ProtostuffMediaSerializer = diff --git a/tpc/src/serializers/protostuff/ProtostuffJson.java b/tpc/src/serializers/protostuff/ProtostuffJson.java index 4eb77ee..e9bb479 100644 --- a/tpc/src/serializers/protostuff/ProtostuffJson.java +++ b/tpc/src/serializers/protostuff/ProtostuffJson.java @@ -8,9 +8,7 @@ import com.dyuproject.protostuff.Schema; import com.dyuproject.protostuff.runtime.RuntimeSchema; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.protostuff.media.MediaContent; /** @@ -24,9 +22,23 @@ public final class ProtostuffJson public static void register(TestGroups groups) { // manual (hand-coded schema, no autoboxing) - groups.media.add(JavaBuiltIn.mediaTransformer, JsonManualMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, JsonManualMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); // runtime (reflection) - groups.media.add(JavaBuiltIn.mediaTransformer, JsonRuntimeMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, JsonRuntimeMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); /* protostuff has too many entries diff --git a/tpc/src/serializers/protostuff/ProtostuffSmile.java b/tpc/src/serializers/protostuff/ProtostuffSmile.java index ae68f63..8c218d6 100644 --- a/tpc/src/serializers/protostuff/ProtostuffSmile.java +++ b/tpc/src/serializers/protostuff/ProtostuffSmile.java @@ -2,14 +2,11 @@ import static serializers.protostuff.Protostuff.MEDIA_CONTENT_SCHEMA; -import com.dyuproject.protostuff.LinkedBuffer; import com.dyuproject.protostuff.Schema; import com.dyuproject.protostuff.SmileIOUtil; import com.dyuproject.protostuff.runtime.RuntimeSchema; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.protostuff.media.MediaContent; /** @@ -23,9 +20,23 @@ public final class ProtostuffSmile public static void register(TestGroups groups) { // manual (hand-coded schema, no autoboxing) - groups.media.add(JavaBuiltIn.mediaTransformer, SmileManualMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, SmileManualMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); // runtime (reflection) - groups.media.add(JavaBuiltIn.mediaTransformer, SmileRuntimeMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, SmileRuntimeMediaSerializer, + new SerFeatures( + SerFormat.JSON, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); /* protostuff has too many entries diff --git a/tpc/src/serializers/protostuff/ProtostuffXml.java b/tpc/src/serializers/protostuff/ProtostuffXml.java index 5fa0526..463b5aa 100644 --- a/tpc/src/serializers/protostuff/ProtostuffXml.java +++ b/tpc/src/serializers/protostuff/ProtostuffXml.java @@ -6,12 +6,8 @@ import com.dyuproject.protostuff.Schema; import com.dyuproject.protostuff.runtime.RuntimeSchema; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import serializers.protostuff.media.MediaContent; -import serializers.protostuff.media.Media; -import serializers.protostuff.media.Image; public final class ProtostuffXml { @@ -19,9 +15,23 @@ public final class ProtostuffXml public static void register(TestGroups groups) { // manual (hand-coded schema, no autoboxing) - groups.media.add(JavaBuiltIn.mediaTransformer, XmlManualMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, XmlManualMediaSerializer, + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); // runtime (reflection) - groups.media.add(JavaBuiltIn.mediaTransformer, XmlRuntimeMediaSerializer); + groups.media.add(JavaBuiltIn.mediaTransformer, XmlRuntimeMediaSerializer, + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); /* protostuff has too many entries diff --git a/tpc/src/serializers/xml/ExiExificient.java b/tpc/src/serializers/xml/ExiExificient.java index 3f4e616..d01cab6 100644 --- a/tpc/src/serializers/xml/ExiExificient.java +++ b/tpc/src/serializers/xml/ExiExificient.java @@ -12,14 +12,20 @@ import com.siemens.ct.exi.api.stream.StAXEncoder; import com.siemens.ct.exi.helpers.DefaultEXIFactory; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; public class ExiExificient { public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new ExificientSerializer()); + groups.media.add(JavaBuiltIn.mediaTransformer, new ExificientSerializer(), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } public static final class ExificientSerializer extends BaseStaxMediaSerializer diff --git a/tpc/src/serializers/xml/Jaxb.java b/tpc/src/serializers/xml/Jaxb.java index e92ea2d..632bf64 100644 --- a/tpc/src/serializers/xml/Jaxb.java +++ b/tpc/src/serializers/xml/Jaxb.java @@ -5,9 +5,7 @@ import javax.xml.bind.*; import javax.xml.stream.*; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import data.media.MediaContent; @@ -20,7 +18,14 @@ public static void register(TestGroups groups) { groups.media.add(JavaBuiltIn.mediaTransformer, new Jaxb("JAXB/aalto", MediaContent.class, - new InputFactoryImpl(), new OutputFactoryImpl())); + new InputFactoryImpl(), new OutputFactoryImpl()), + new SerFeatures( + SerFormat.XML, + SerGraph.FULL_GRAPH, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); } private final String name; diff --git a/tpc/src/serializers/xml/XmlJavolution.java b/tpc/src/serializers/xml/XmlJavolution.java index 11f4450..9ce2db7 100644 --- a/tpc/src/serializers/xml/XmlJavolution.java +++ b/tpc/src/serializers/xml/XmlJavolution.java @@ -5,9 +5,7 @@ import java.util.ArrayList; import java.util.List; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import javolution.text.CharArray; import javolution.xml.XMLBinding; @@ -25,7 +23,14 @@ public class XmlJavolution public static void register(TestGroups groups) { - groups.media.add(JavaBuiltIn.mediaTransformer, new JavolutionSerializer("", MediaBinding, MediaContent.class)); + groups.media.add(JavaBuiltIn.mediaTransformer, new JavolutionSerializer("", MediaBinding, MediaContent.class), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); // commented-out by dyu: use the non-abbreviated version //groups.media.add(JavaBuiltIn.MediaTransformer, new JavolutionSerializer("-abbrev", MediaBindingAbbreviated, MediaContent.class)); } diff --git a/tpc/src/serializers/xml/XmlStax.java b/tpc/src/serializers/xml/XmlStax.java index 5538feb..28ac2cb 100644 --- a/tpc/src/serializers/xml/XmlStax.java +++ b/tpc/src/serializers/xml/XmlStax.java @@ -4,8 +4,7 @@ import javax.xml.stream.*; -import serializers.JavaBuiltIn; -import serializers.TestGroups; +import serializers.*; /** * Codec that works with standard full Stax implementations, where @@ -34,13 +33,35 @@ public class XmlStax public static void register(TestGroups groups, boolean woodstox, boolean aalto, boolean fastinfoset) { if (woodstox) { - groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[0])); + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[0]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); + } if (aalto) { - groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[1])); + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[1]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); } if (fastinfoset) { - groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[2])); + groups.media.add(JavaBuiltIn.mediaTransformer, new StaxMediaSerializer(HANDLERS[2]), + new SerFeatures( + SerFormat.XML, + SerGraph.UNKNOWN, + SerClass.MANUAL_OPT, + "" + ) + ); } } diff --git a/tpc/src/serializers/xml/XmlXStream.java b/tpc/src/serializers/xml/XmlXStream.java index 8106701..34e04c1 100644 --- a/tpc/src/serializers/xml/XmlXStream.java +++ b/tpc/src/serializers/xml/XmlXStream.java @@ -21,9 +21,7 @@ import javax.xml.stream.XMLInputFactory; import javax.xml.stream.XMLOutputFactory; -import serializers.JavaBuiltIn; -import serializers.Serializer; -import serializers.TestGroups; +import serializers.*; import java.io.Writer; import java.util.ArrayList; @@ -52,7 +50,14 @@ public HierarchicalStreamWriter createWriter(Writer out) { //return new PrettyPrintWriter(out, xmlFriendlyReplacer()); return new CompactWriter(out, xmlFriendlyReplacer()); } - }), MediaConfiguration)); + }), MediaConfiguration), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.ZERO_KNOWLEDGE, + "" + ) + ); // commented-out by dyu: use the non-abbreviated version /*groups.media.add(JavaBuiltIn.MediaTransformer, new ConverterSerializer("xml/xstream+c-abbrev", @@ -68,7 +73,14 @@ public HierarchicalStreamWriter createWriter(Writer out) { // TODO: This doesn't work yet. Need to properly handle optional fields in readMedia/readImage. // commented-out by dyu: use the non-abbreviated version (+c) because the perf of the default sux. //groups.media.add(JavaBuiltIn.MediaTransformer, XStream.mkStaxSerializer(h, "", EmptyConfiguration)); - groups.media.add(JavaBuiltIn.mediaTransformer, XmlXStream.mkStaxSerializer(h, "+c", MediaConfiguration)); + groups.media.add(JavaBuiltIn.mediaTransformer, XmlXStream.mkStaxSerializer(h, "+c", MediaConfiguration), + new SerFeatures( + SerFormat.XML, + SerGraph.FLAT_TREE, + SerClass.MANUAL_OPT, + "" + ) + ); //groups.media.add(JavaBuiltIn.MediaTransformer, XStream.mkStaxSerializer(h, "+c-abbrev", MediaConfigurationAbbreviated)); } } diff --git a/tpc/support/intellij/Main.iml b/tpc/support/intellij/Main.iml index bfc87ea..1156d3c 100644 --- a/tpc/support/intellij/Main.iml +++ b/tpc/support/intellij/Main.iml @@ -21,14 +21,24 @@ - + - + + - + + + + + + + + + +