Skip to content

Commit

Permalink
Improved some performance test
Browse files Browse the repository at this point in the history
  • Loading branch information
Giuseppe Gerla committed Sep 22, 2017
1 parent 45ea91b commit c0af166
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,23 @@ public class TestObjectClass {
private String campo6;
private String campo7;
private String campo8;
private String campo9;
private String campo10;
private String campo11;
private String campo12;
private String campo13;
private String campo14;
private String campo15;
private String campo16;

protected TestObjectClass() {

}

public TestObjectClass(String campo1, String campo2, String campo3, String campo4, String campo5,
String campo6, String campo7, String campo8) {
String campo6, String campo7, String campo8, String campo9, String campo10,
String campo11, String campo12, String campo13, String campo14, String campo15,
String campo16) {
super();
this.campo1 = campo1;
this.campo2 = campo2;
Expand All @@ -25,7 +35,16 @@ public TestObjectClass(String campo1, String campo2, String campo3, String campo
this.campo6 = campo6;
this.campo7 = campo7;
this.campo8 = campo8;
this.campo9 = campo9;
this.campo10 = campo10;
this.campo11 = campo11;
this.campo12 = campo12;
this.campo13 = campo13;
this.campo14 = campo14;
this.campo15 = campo15;
this.campo16 = campo16;
}

public String getCampo1() {
return campo1;
}
Expand All @@ -50,4 +69,36 @@ public String getCampo7() {
public String getCampo8() {
return campo8;
}

public String getCampo9() {
return campo9;
}

public String getCampo10() {
return campo10;
}

public String getCampo11() {
return campo11;
}

public String getCampo12() {
return campo12;
}

public String getCampo13() {
return campo13;
}

public String getCampo14() {
return campo14;
}

public String getCampo15() {
return campo15;
}

public String getCampo16() {
return campo16;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -261,34 +261,37 @@ public void testMapSerializer() throws POxOSerializerException, IOException {
@Test
public void testListMapStringStringSerializer() throws POxOSerializerException, IOException {
List<Map<String, String>> testData = new ArrayList<Map<String, String>>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 2500; i++) {
Map<String, String> mapData = new HashMap<String, String>();
for (int j = 0; j < 8; j++) {
for (int j = 0; j < 16; j++) {
mapData.put("key" + j, this.getClass().getSimpleName() + j);
}
testData.add(mapData);
}

GenericTypeContainer gt = new GenericTypeContainer();
gt.setListMap(testData);
POxOSerializer serializer = new POxOSerializer();

long checkTime = System.currentTimeMillis();
byte[] output = serializer.serialize(testData);
byte[] output = serializer.serialize(gt);
checkTime = System.currentTimeMillis() - checkTime;
System.out.println("serialization time " + checkTime);

writeDataToFile("testListMap", output);

checkTime = System.currentTimeMillis();
List<Map<String, String>> testDataCheck = (List<Map<String, String>>)serializer.deserialize(output);
GenericTypeContainer testDataCheck = (GenericTypeContainer)serializer.deserialize(output);
checkTime = System.currentTimeMillis() - checkTime;
System.out.println("deserialization time " + checkTime);
assertEquals(testDataCheck.size(), testData.size());
assertEquals(testDataCheck.getListMap().size(), testData.size());
}

@Test
public void testListListStringSerializer() throws POxOSerializerException, IOException {
List<List<String>> testData = new ArrayList<List<String>>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 2500; i++) {
List<String> mapData = new ArrayList<String>();
for (int j = 0; j < 8; j++) {
for (int j = 0; j < 16; j++) {
mapData.add(this.getClass().getSimpleName() + j);
}
testData.add(mapData);
Expand All @@ -300,7 +303,8 @@ public void testListListStringSerializer() throws POxOSerializerException, IOExc
byte[] output = serializer.serialize(testData);
checkTime = System.currentTimeMillis() - checkTime;
System.out.println("serialization time " + checkTime);

writeDataToFile("testListList", output);

checkTime = System.currentTimeMillis();
List<List<String>> testDataCheck = (List<List<String>>)serializer.deserialize(output);
checkTime = System.currentTimeMillis() - checkTime;
Expand All @@ -311,8 +315,16 @@ public void testListListStringSerializer() throws POxOSerializerException, IOExc
@Test
public void testListObjectSerializer() throws POxOSerializerException, IOException {
List<TestObjectClass> testData = new ArrayList<TestObjectClass>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 10000; i++) {
TestObjectClass mapData = new TestObjectClass(this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
Expand Down Expand Up @@ -340,8 +352,16 @@ public void testListObjectSerializer() throws POxOSerializerException, IOExcepti
@Test
public void testGenericTypeContainer() throws POxOSerializerException, IOException {
List<TestObjectClass> testData = new ArrayList<TestObjectClass>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 10000; i++) {
TestObjectClass mapData = new TestObjectClass(this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
this.getClass().getSimpleName(),
Expand All @@ -362,9 +382,9 @@ public void testGenericTypeContainer() throws POxOSerializerException, IOExcepti
assertEquals(testDataCheck.getListObject().size(), testData.size());

List<List<String>> testDataListList = new ArrayList<List<String>>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 10000; i++) {
List<String> mapData = new ArrayList<String>();
for (int j = 0; j < 8; j++) {
for (int j = 0; j < 16; j++) {
mapData.add(this.getClass().getSimpleName() + j);
}
testDataListList.add(mapData);
Expand All @@ -377,12 +397,12 @@ public void testGenericTypeContainer() throws POxOSerializerException, IOExcepti
output = serializer.serialize(container);
writeDataToFile("testListList", output);
GenericTypeContainer testDataCheckListList = (GenericTypeContainer)serializer.deserialize(output);
assertEquals(testDataCheckListList.getListList().size(), testData.size());
assertEquals(testDataCheckListList.getListList().size(), testDataListList.size());

List<Map<String, String>> testDataListMap = new ArrayList<Map<String, String>>();
for (int i = 0; i < 2100; i++) {
for (int i = 0; i < 10000; i++) {
Map<String, String> mapData = new HashMap<String, String>();
for (int j = 0; j < 8; j++) {
for (int j = 0; j < 16; j++) {
mapData.put("key" + j, this.getClass().getSimpleName() + j);
}
testDataListMap.add(mapData);
Expand All @@ -396,7 +416,7 @@ public void testGenericTypeContainer() throws POxOSerializerException, IOExcepti
writeDataToFile("testListMap", output);
GenericTypeContainer testDataCheckListMap = (GenericTypeContainer)serializer
.deserialize(output);
assertEquals(testDataCheckListMap.getListMap().size(), testData.size());
assertEquals(testDataCheckListMap.getListMap().size(), testDataListMap.size());

Map<String, List<Integer>> testDataMapList = new HashMap<String, List<Integer>>();
for (int i = 0; i < 2100; i++) {
Expand All @@ -415,6 +435,6 @@ public void testGenericTypeContainer() throws POxOSerializerException, IOExcepti
writeDataToFile("testMapList", output);
GenericTypeContainer testDataCheckMapList = (GenericTypeContainer)serializer
.deserialize(output);
assertEquals(testDataCheckMapList.getMapList().size(), testData.size());
assertEquals(testDataCheckMapList.getMapList().size(), testDataMapList.size());
}
}

0 comments on commit c0af166

Please sign in to comment.