Skip to content
Browse files

kryo2 doc fix

  • Loading branch information...
1 parent aeec8b6 commit 21b10405f3736585f1e89e548bf54e7eb87740ef @michaelmosmann michaelmosmann committed
View
248 jdk-1.6-parent/serializer-kryo2/README.md
@@ -10,7 +10,7 @@ There are not as many usefull features so far, but one could be very usefull: An
### Maven Setup
-There is a Version for Wicket 1.5.x starting with 1.5.9.
+There is a Version for Wicket 1.5.x starting with 1.5.9,but API changed since 1.5.10
<dependency>
<groupId>org.wicketstuff</groupId>
@@ -32,10 +32,12 @@ Change Application.init() like this:
super.init();
+ IReportOutput reportOutput=new LoggerReportOutput();
+
// output of report of type sizes, sorted tree report (by size), aggregated tree
ISerializedObjectTreeProcessor typeAndSortedTreeAndCollapsedSortedTreeProcessors = TreeProcessors.listOf(
- new TypeSizeReport(), new SortedTreeSizeReport(), new SimilarNodeTreeTransformator(
- new SortedTreeSizeReport()));
+ new TypeSizeReport(reportOutput), new SortedTreeSizeReport(reportOutput), new SimilarNodeTreeTransformator(
+ new SortedTreeSizeReport(reportOutput)));
// strips class object writes from tree
TreeTransformator treeProcessors = new TreeTransformator(
@@ -76,128 +78,130 @@ And with this SamplePage:
DEBUG - KryoSerializer - Buffer size: '1M'
DEBUG - KryoSerializer - Going to serialize: '[Page class = org.wicketstuff.pageserializer.kryo2.examples.SamplePage, id = 0, render count = 1]'
- DEBUG - TypeSizeReport -
- ====================================================================
- |Type.........................................................bytes|
- --------------------------------------------------------------------
- |org.wicketstuff.pageserializer.kryo2.examples.SamplePage.......183|
- |org.wicketstuff.pageserializer.kryo2.examples.SamplePage$1......80|
- |org.apache.wicket.markup.html.list.ListItem.....................70|
- |java.lang.Integer...............................................63|
- |org.apache.wicket.markup.html.basic.Label.......................63|
- |java.lang.String................................................34|
- |org.apache.wicket.markup.html.list.ListItemModel................12|
- |java.util.Arrays$ArrayList.......................................3|
- |org.apache.wicket.request.mapper.parameter.PageParameters........3|
- |org.apache.wicket.model.util.WildcardListModel...................2|
- |[Ljava.lang.Object;..............................................2|
- |java.lang.Boolean................................................1|
- ====================================================================
-
- DEBUG - TreeSizeReport -
- ===============================================================================================
- | #|Type.................................................................%|.sum|.local|.child|
- -----------------------------------------------------------------------------------------------
- | #0|org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0).......100%|.516|...181|...335|
- | #4| org.apache.wicket.markup.html.list.ListView(list)................62%|.323|....74|...249|
- | #6| [Ljava.lang.Object;............................................41%|.212|.....2|...210|
- | #7| org.apache.wicket.markup.html.list.ListItem(0)...............25%|.134|....51|....83|
- |#10| org.apache.wicket.markup.html.basic.Label(label)...........13%|..71|....53|....18|
- |#16| java.lang.String("labe...")...............................1%|...6|.....6|.....0|
- |#12| org.apache.wicket.markup.html.list.ListItemModel..........0%|...5|.....3|.....2|
- |#13| java.lang.Integer(=0)...................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list).......0%|...1|.....1|.....0|
- |#14| java.lang.Integer(=1074999450)............................0%|...5|.....5|.....0|
- |#15| java.lang.Integer(=-1)....................................0%|...1|.....1|.....0|
- | #7| org.apache.wicket.markup.html.list.ListItem(0)............0%|...1|.....1|.....0|
- |#17| java.lang.Integer(=1074999450)..............................0%|...5|.....5|.....0|
- |#19| java.lang.String("0").......................................0%|...3|.....3|.....0|
- |#12| org.apache.wicket.markup.html.list.ListItemModel............0%|...1|.....1|.....0|
- |#18| java.lang.Integer(=-1)......................................0%|...1|.....1|.....0|
- |#20| java.lang.Integer(=0).......................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list)...........0%|...1|.....1|.....0|
- |#21| org.apache.wicket.markup.html.list.ListItem(1)................7%|..38|.....8|....30|
- |#22| org.apache.wicket.markup.html.basic.Label(label)............3%|..18|.....5|....13|
- |#23| org.apache.wicket.markup.html.list.ListItemModel..........0%|...5|.....3|.....2|
- |#24| java.lang.Integer(=1)...................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list).......0%|...1|.....1|.....0|
- |#25| java.lang.Integer(=1074999450)............................0%|...5|.....5|.....0|
- |#26| java.lang.Integer(=-1)....................................0%|...1|.....1|.....0|
- |#16| java.lang.String("labe...")...............................0%|...1|.....1|.....0|
- |#21| org.apache.wicket.markup.html.list.ListItem(1)............0%|...1|.....1|.....0|
- |#27| java.lang.Integer(=1074999450)..............................0%|...5|.....5|.....0|
- |#29| java.lang.String("1").......................................0%|...3|.....3|.....0|
- |#23| org.apache.wicket.markup.html.list.ListItemModel............0%|...1|.....1|.....0|
- |#28| java.lang.Integer(=-1)......................................0%|...1|.....1|.....0|
- |#30| java.lang.Integer(=1).......................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list)...........0%|...1|.....1|.....0|
- |#31| org.apache.wicket.markup.html.list.ListItem(2)................7%|..38|.....8|....30|
- |#32| org.apache.wicket.markup.html.basic.Label(label)............3%|..18|.....5|....13|
- |#33| org.apache.wicket.markup.html.list.ListItemModel..........0%|...5|.....3|.....2|
- |#34| java.lang.Integer(=2)...................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list).......0%|...1|.....1|.....0|
- |#35| java.lang.Integer(=1074999450)............................0%|...5|.....5|.....0|
- |#36| java.lang.Integer(=-1)....................................0%|...1|.....1|.....0|
- |#16| java.lang.String("labe...")...............................0%|...1|.....1|.....0|
- |#31| org.apache.wicket.markup.html.list.ListItem(2)............0%|...1|.....1|.....0|
- |#37| java.lang.Integer(=1074999450)..............................0%|...5|.....5|.....0|
- |#39| java.lang.String("2").......................................0%|...3|.....3|.....0|
- |#33| org.apache.wicket.markup.html.list.ListItemModel............0%|...1|.....1|.....0|
- |#38| java.lang.Integer(=-1)......................................0%|...1|.....1|.....0|
- |#40| java.lang.Integer(=2).......................................0%|...1|.....1|.....0|
- | #4| org.apache.wicket.markup.html.list.ListView(list)...........0%|...1|.....1|.....0|
- |#42| org.apache.wicket.model.util.WildcardListModel..................3%|..17|.....2|....15|
- |#44| java.util.Arrays$ArrayList....................................2%|..15|.....3|....12|
- |#46| java.lang.String("A").......................................0%|...4|.....4|.....0|
- |#47| java.lang.String("B").......................................0%|...4|.....4|.....0|
- |#48| java.lang.String("C").......................................0%|...4|.....4|.....0|
- |#50| java.lang.Integer(=1074999450)..................................0%|...5|.....5|.....0|
- |#52| java.lang.String("list")........................................0%|...5|.....5|.....0|
- |#54| java.lang.Integer(=MAX).........................................0%|...5|.....5|.....0|
- | #0| org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0).....0%|...2|.....2|.....0|
- |#49| java.lang.Integer(=0)...........................................0%|...1|.....1|.....0|
- |#51| java.lang.Integer(=-1)..........................................0%|...1|.....1|.....0|
- |#53| java.lang.Boolean...............................................0%|...1|.....1|.....0|
- |#55| java.lang.Integer(=1074475162)....................................0%|...5|.....5|.....0|
- |#59| org.apache.wicket.request.mapper.parameter.PageParameters.........0%|...3|.....3|.....0|
- | #2| java.lang.Integer(=1).............................................0%|...1|.....1|.....0|
- |#56| java.lang.Integer(=-1)............................................0%|...1|.....1|.....0|
- |#57| java.lang.Integer(=0).............................................0%|...1|.....1|.....0|
- |#60| java.lang.Integer(=1).............................................0%|...1|.....1|.....0|
- ===============================================================================================
-
- DEBUG - TreeSizeReport -
- ====================================================================================================================
- | #|Type.....................................................................................%|.sum|.local|.child|
- --------------------------------------------------------------------------------------------------------------------
- | #0|org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0)...........................100%|.516|...181|...335|
- | #4| org.apache.wicket.markup.html.list.ListView(list)....................................62%|.323|....74|...249|
- | #6| [Ljava.lang.Object;................................................................41%|.212|.....2|...210|
- |null| org.apache.wicket.markup.html.list.ListItem(0|1|2)...............................40%|.210|....67|...143|
- |null| org.apache.wicket.markup.html.basic.Label(label)...............................20%|.107|....63|....44|
- |null| java.lang.Integer(=1074999450|=-1)............................................3%|..18|....18|.....0|
- |null| org.apache.wicket.markup.html.list.ListItemModel..............................2%|..15|.....9|.....6|
- |null| java.lang.Integer(=0|=1|=2).................................................0%|...3|.....3|.....0|
- |null| org.apache.wicket.markup.html.list.ListView(list)...........................0%|...3|.....3|.....0|
- |null| java.lang.String("labe...")...................................................1%|...8|.....8|.....0|
- |null| org.apache.wicket.markup.html.list.ListItem(0|1|2)............................0%|...3|.....3|.....0|
- |null| java.lang.Integer(=1074999450|=-1|=0|=1074999450|=-1|=1|=1074999450|=-1|=2).....4%|..21|....21|.....0|
- |null| java.lang.String("0"|"1"|"2")...................................................1%|...9|.....9|.....0|
- |null| org.apache.wicket.markup.html.list.ListItemModel................................0%|...3|.....3|.....0|
- |null| org.apache.wicket.markup.html.list.ListView(list)...............................0%|...3|.....3|.....0|
- | #42| org.apache.wicket.model.util.WildcardListModel......................................3%|..17|.....2|....15|
- | #44| java.util.Arrays$ArrayList........................................................2%|..15|.....3|....12|
- |null| java.lang.String("A"|"B"|"C")...................................................2%|..12|....12|.....0|
- |null| java.lang.Integer(=0|=1074999450|=-1|=MAX)..........................................2%|..12|....12|.....0|
- | #52| java.lang.String("list")............................................................0%|...5|.....5|.....0|
- | #0| org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0).........................0%|...2|.....2|.....0|
- | #53| java.lang.Boolean...................................................................0%|...1|.....1|.....0|
- |null| java.lang.Integer(=1|=1074475162|=-1|=0)..............................................1%|...9|.....9|.....0|
- | #59| org.apache.wicket.request.mapper.parameter.PageParameters.............................0%|...3|.....3|.....0|
- ====================================================================================================================
+ DEBUG - LoggerReportOutput - TypeSizeReport
+ ==================================================================
+ |bytes|Type |
+ ------------------------------------------------------------------
+ | 183|org.wicketstuff.pageserializer.kryo2.examples.SamplePage |
+ | 80|org.wicketstuff.pageserializer.kryo2.examples.SamplePage$1|
+ | 70|org.apache.wicket.markup.html.list.ListItem |
+ | 63|org.apache.wicket.markup.html.basic.Label |
+ | 63|java.lang.Integer |
+ | 34|java.lang.String |
+ | 12|org.apache.wicket.markup.html.list.ListItemModel |
+ | 3|org.apache.wicket.request.mapper.parameter.PageParameters |
+ | 3|java.util.Arrays$ArrayList |
+ | 2|org.apache.wicket.model.util.WildcardListModel |
+ | 2|[Ljava.lang.Object; |
+ | 1|java.lang.Boolean |
+ ==================================================================
+
+ DEBUG - LoggerReportOutput - TreeSizeReport
+ ==============================================================================================
+ | #| %| sum| local| child|Type |
+ ----------------------------------------------------------------------------------------------
+ | #0| 100%| 516| 181| 335|org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0) |
+ | #4| 62%| 323| 74| 249| org.apache.wicket.markup.html.list.ListView(list) |
+ | #6| 41%| 212| 2| 210| [Ljava.lang.Object; |
+ | #7| 25%| 134| 51| 83| org.apache.wicket.markup.html.list.ListItem(0) |
+ |#10| 13%| 71| 53| 18| org.apache.wicket.markup.html.basic.Label(label) |
+ |#16| 1%| 6| 6| 0| java.lang.String("labe...") |
+ |#12| 0%| 5| 3| 2| org.apache.wicket.markup.html.list.ListItemModel |
+ |#13| 0%| 1| 1| 0| java.lang.Integer(=0) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#14| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#15| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ | #7| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItem(0) |
+ |#17| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#19| 0%| 3| 3| 0| java.lang.String("0") |
+ |#12| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItemModel |
+ |#18| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#20| 0%| 1| 1| 0| java.lang.Integer(=0) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#21| 7%| 38| 8| 30| org.apache.wicket.markup.html.list.ListItem(1) |
+ |#22| 3%| 18| 5| 13| org.apache.wicket.markup.html.basic.Label(label) |
+ |#23| 0%| 5| 3| 2| org.apache.wicket.markup.html.list.ListItemModel |
+ |#24| 0%| 1| 1| 0| java.lang.Integer(=1) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#25| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#26| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#16| 0%| 1| 1| 0| java.lang.String("labe...") |
+ |#21| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItem(1) |
+ |#27| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#29| 0%| 3| 3| 0| java.lang.String("1") |
+ |#23| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItemModel |
+ |#28| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#30| 0%| 1| 1| 0| java.lang.Integer(=1) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#31| 7%| 38| 8| 30| org.apache.wicket.markup.html.list.ListItem(2) |
+ |#32| 3%| 18| 5| 13| org.apache.wicket.markup.html.basic.Label(label) |
+ |#33| 0%| 5| 3| 2| org.apache.wicket.markup.html.list.ListItemModel |
+ |#34| 0%| 1| 1| 0| java.lang.Integer(=2) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#35| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#36| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#16| 0%| 1| 1| 0| java.lang.String("labe...") |
+ |#31| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItem(2) |
+ |#37| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#39| 0%| 3| 3| 0| java.lang.String("2") |
+ |#33| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListItemModel |
+ |#38| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#40| 0%| 1| 1| 0| java.lang.Integer(=2) |
+ | #4| 0%| 1| 1| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |#42| 3%| 17| 2| 15| org.apache.wicket.model.util.WildcardListModel |
+ |#44| 2%| 15| 3| 12| java.util.Arrays$ArrayList |
+ |#46| 0%| 4| 4| 0| java.lang.String("A") |
+ |#47| 0%| 4| 4| 0| java.lang.String("B") |
+ |#48| 0%| 4| 4| 0| java.lang.String("C") |
+ |#50| 0%| 5| 5| 0| java.lang.Integer(=1074999450) |
+ |#52| 0%| 5| 5| 0| java.lang.String("list") |
+ |#54| 0%| 5| 5| 0| java.lang.Integer(=MAX) |
+ | #0| 0%| 2| 2| 0| org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0)|
+ |#49| 0%| 1| 1| 0| java.lang.Integer(=0) |
+ |#51| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#53| 0%| 1| 1| 0| java.lang.Boolean |
+ |#55| 0%| 5| 5| 0| java.lang.Integer(=1074475162) |
+ |#59| 0%| 3| 3| 0| org.apache.wicket.request.mapper.parameter.PageParameters |
+ | #2| 0%| 1| 1| 0| java.lang.Integer(=1) |
+ |#56| 0%| 1| 1| 0| java.lang.Integer(=-1) |
+ |#57| 0%| 1| 1| 0| java.lang.Integer(=0) |
+ |#60| 0%| 1| 1| 0| java.lang.Integer(=1) |
+ ==============================================================================================
+
+ DEBUG - LoggerReportOutput - TreeSizeReport
+ ===================================================================================================================
+ | #| %| sum| local| child|Type |
+ -------------------------------------------------------------------------------------------------------------------
+ | #0| 100%| 516| 181| 335|org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0) |
+ | #4| 62%| 323| 74| 249| org.apache.wicket.markup.html.list.ListView(list) |
+ | #6| 41%| 212| 2| 210| [Ljava.lang.Object; |
+ |null| 40%| 210| 67| 143| org.apache.wicket.markup.html.list.ListItem(0|1|2) |
+ |null| 20%| 107| 63| 44| org.apache.wicket.markup.html.basic.Label(label) |
+ |null| 3%| 18| 18| 0| java.lang.Integer(=1074999450|=-1) |
+ |null| 2%| 15| 9| 6| org.apache.wicket.markup.html.list.ListItemModel |
+ |null| 0%| 3| 3| 0| java.lang.Integer(=0|=1|=2) |
+ |null| 0%| 3| 3| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ |null| 1%| 8| 8| 0| java.lang.String("labe...") |
+ |null| 0%| 3| 3| 0| org.apache.wicket.markup.html.list.ListItem(0|1|2) |
+ |null| 4%| 21| 21| 0| java.lang.Integer(=1074999450|=-1|=0|=1074999450|=-1|=1|=1074999450|=-1|=2)|
+ |null| 1%| 9| 9| 0| java.lang.String("0"|"1"|"2") |
+ |null| 0%| 3| 3| 0| org.apache.wicket.markup.html.list.ListItemModel |
+ |null| 0%| 3| 3| 0| org.apache.wicket.markup.html.list.ListView(list) |
+ | #42| 3%| 17| 2| 15| org.apache.wicket.model.util.WildcardListModel |
+ | #44| 2%| 15| 3| 12| java.util.Arrays$ArrayList |
+ |null| 2%| 12| 12| 0| java.lang.String("A"|"B"|"C") |
+ |null| 2%| 12| 12| 0| java.lang.Integer(=0|=1074999450|=-1|=MAX) |
+ | #52| 0%| 5| 5| 0| java.lang.String("list") |
+ | #0| 0%| 2| 2| 0| org.wicketstuff.pageserializer.kryo2.examples.SamplePage(0) |
+ | #53| 0%| 1| 1| 0| java.lang.Boolean |
+ |null| 1%| 9| 9| 0| java.lang.Integer(=1|=1074475162|=-1|=0) |
+ | #59| 0%| 3| 3| 0| org.apache.wicket.request.mapper.parameter.PageParameters |
+ ===================================================================================================================
You can customize a lot if you want to, but maybe this is a good start for some investigation.
+### Single file for each report instead of logging
+
View
4 ...alizer-kryo2/src/test/java/org/wicketstuff/pageserializer/kryo2/examples/Application.java
@@ -20,6 +20,8 @@
*/
package org.wicketstuff.pageserializer.kryo2.examples;
+import java.io.File;
+
import org.apache.wicket.protocol.http.WebApplication;
import org.apache.wicket.util.file.Files;
import org.apache.wicket.util.lang.Bytes;
@@ -36,6 +38,8 @@
import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.TreeTransformator;
import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.TypeSizeReport;
import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.filter.TypeFilter;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.io.DirectoryBasedReportOutput;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.io.Keys;
import org.wicketstuff.pageserializer.kryo2.inspecting.listener.ISerializationListener;
import org.wicketstuff.pageserializer.kryo2.inspecting.listener.SerializationListeners;
import org.wicketstuff.pageserializer.kryo2.inspecting.validation.DefaultJavaSerializationValidator;
View
83 ...va/org/wicketstuff/pageserializer/kryo2/examples/ApplicationWithDirectoryBasedOutput.java
@@ -0,0 +1,83 @@
+package org.wicketstuff.pageserializer.kryo2.examples;
+
+import java.io.File;
+import java.util.UUID;
+
+import org.apache.wicket.Page;
+import org.apache.wicket.protocol.http.WebApplication;
+import org.apache.wicket.util.file.Files;
+import org.apache.wicket.util.lang.Bytes;
+import org.wicketstuff.pageserializer.kryo2.inspecting.InspectingKryoSerializer;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.AnalyzingSerializationListener;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.ComponentIdAsLabel;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.ISerializedObjectTreeProcessor;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.NativeTypesAsLabel;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.TreeProcessors;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.RenderTreeProcessor;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.SimilarNodeTreeTransformator;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.SortedTreeSizeReport;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.TreeTransformator;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.TypeSizeReport;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.d3js.D3DataFileRenderer;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.filter.TypeFilter;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.io.DirectoryBasedReportOutput;
+import org.wicketstuff.pageserializer.kryo2.inspecting.analyze.report.io.Keys;
+import org.wicketstuff.pageserializer.kryo2.inspecting.listener.ISerializationListener;
+import org.wicketstuff.pageserializer.kryo2.inspecting.listener.SerializationListeners;
+import org.wicketstuff.pageserializer.kryo2.inspecting.validation.DefaultJavaSerializationValidator;
+
+
+public class ApplicationWithDirectoryBasedOutput extends WebApplication {
+
+ @Override
+ public Class<? extends Page> getHomePage() {
+ return SamplePage.class;
+ }
+
+ @Override
+ protected void init() {
+ super.init();
+
+ File outputDirectory = tempDirectory("kryo2-reports");
+ System.out.println("Reports in: "+outputDirectory);
+
+ DirectoryBasedReportOutput output = new DirectoryBasedReportOutput(outputDirectory);
+
+ // output of report of type sizes, sorted tree report (by size), aggregated tree
+ ISerializedObjectTreeProcessor typeAndSortedTreeAndCollapsedSortedTreeProcessors = TreeProcessors.listOf(
+ new TypeSizeReport(output.with(Keys.withNameAndFileExtension("typesize", "txt"))),
+ new SortedTreeSizeReport(output.with(Keys.withNameAndFileExtension("treesize", "txt"))),
+ new SimilarNodeTreeTransformator(new SortedTreeSizeReport(output.with(Keys.withNameAndFileExtension("sorted-treesize", "txt")))),
+ new RenderTreeProcessor(output.with(Keys.withNameAndFileExtension("d3js-chart", "html")),new D3DataFileRenderer()));
+
+ // strips class object writes from tree
+ TreeTransformator treeProcessors = new TreeTransformator(
+ typeAndSortedTreeAndCollapsedSortedTreeProcessors,
+ TreeTransformator.strip(new TypeFilter(Class.class)));
+
+ // serialization listener notified on every written object
+ ISerializationListener serializationListener = SerializationListeners.listOf(
+ new DefaultJavaSerializationValidator(), new AnalyzingSerializationListener(
+ new NativeTypesAsLabel(new ComponentIdAsLabel()), treeProcessors));
+
+
+ InspectingKryoSerializer serializer = new InspectingKryoSerializer(Bytes.megabytes(1L),
+ serializationListener);
+
+ getFrameworkSettings().setSerializer(serializer);
+
+
+ }
+
+ private File tempDirectory(String prefix) {
+ File baseDir = new File(System.getProperty("java.io.tmpdir"));
+ String baseName = prefix + "-" + UUID.randomUUID().toString();
+
+ File tempDir = new File(baseDir, baseName);
+ if (tempDir.mkdir()) {
+ return tempDir;
+ }
+
+ throw new RuntimeException("Could not create tempdir " + baseName + " in " + baseDir);
+ }
+}
View
58 ...va/org/wicketstuff/pageserializer/kryo2/examples/ExampleTestWithDirectoryBasedOutput.java
@@ -0,0 +1,58 @@
+/**
+ * Copyright (C)
+ * 2008 Jeremy Thomerson <jeremy@thomersonfamily.com>
+ * 2012 Michael Mosmann <michael@mosmann.de>
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.wicketstuff.pageserializer.kryo2.examples;
+
+import org.apache.wicket.serialize.ISerializer;
+import org.apache.wicket.util.tester.WicketTester;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ExampleTestWithDirectoryBasedOutput
+{
+ private WicketTester tester;
+
+ @Before
+ public void setUp()
+ {
+ tester = new WicketTester(new ApplicationWithDirectoryBasedOutput());
+ }
+
+ @After
+ public void tearDown()
+ {
+ tester.destroy();
+ }
+
+ @Test
+ public void serializeSamplePage() {
+ // start and render the test page
+ SamplePage page = tester.startPage(SamplePage.class);
+
+ // assert rendered page class
+ tester.assertRenderedPage(SamplePage.class);
+
+ ISerializer pageSerializer = Application.get().getFrameworkSettings().getSerializer();
+
+ pageSerializer.serialize(page);
+ }
+
+}

0 comments on commit 21b1040

Please sign in to comment.
Something went wrong with that request. Please try again.