📄 marshallingperftest.java
字号:
/*****************************************************************************/
/* Software Testing Automation Framework (STAF) */
/* (C) Copyright IBM Corp. 2006 */
/* */
/* This software is licensed under the Common Public License (CPL) V1.0. */
/*****************************************************************************/
//===========================================================================
// MarshallingPerfTest - Tests performance of Java marshalling and formatObject
//===========================================================================
// Accepts: The number of entries to marshall
// Returns: Nothing
//===========================================================================
// Purpose: Create some marshalled data for a specified number of entries to
// test performance of Java marshalling and formatObject.
//
// Expected Rseult:
/*
C:\dev\sf\rel\win32\staf\retail\bin>java MarshallingPerfTest 100000
************************************************************
Test for Errors in Marshalling, FormatObject, and Unmarshall
************************************************************
Test for errors using a list with 1 entries of map class objects with 2 keys
Verify you can format, marshall, and unmarshall an object that references a map
class but does not define the map class in the context:
FormatObject result without map class definition in context:
[
{
key1 : Value 1 1
key2 : Value 2 1
staf-map-class-name: STAF/Test/MyMapClassDefinition
}
]
Marshalled string:
@SDT/[1:127:@SDT/{:116::4:key1@SDT/$S:9:Value 1 1:4:key2@SDT/$S:9:Value 2 1:19:s
taf-map-class-name@SDT/$S:30:STAF/Test/MyMapClassDefinition
Length of marshalled data: 139
Unmarshall and call FormatObject on the context:
[
{
key1 : Value 1 1
staf-map-class-name: STAF/Test/MyMapClassDefinition
key2 : Value 2 1
}
]
Print root list object as a formatted string:
[
{
key1 : Value 1 1
staf-map-class-name: STAF/Test/MyMapClassDefinition
key2 : Value 2 1
}
]
FormatObject result with wrong map class definition in context:
[
{
key1 : Value 1 1
key2 : Value 2 1
staf-map-class-name: STAF/Test/MyMapClassDefinition
}
]
Marshalling string with wrong map class definition in context:
@SDT/*:289:@SDT/{:139::13:map-class-map@SDT/{:111::31:STAF/Test/MyMapClassDefini
tion2@SDT/{:66::4:keys@SDT/[0:0::4:name@SDT/$S:31:STAF/Test/MyMapClassDefinition
2@SDT/[1:127:@SDT/{:116::4:key1@SDT/$S:9:Value 1 1:4:key2@SDT/$S:9:Value 2 1:19:
staf-map-class-name@SDT/$S:30:STAF/Test/MyMapClassDefinition
Length of marshalled data: 300
Unmarshall and call FormatObject on the context:
[
{
key1 : Value 1 1
key2 : Value 2 1
staf-map-class-name: STAF/Test/MyMapClassDefinition
}
]
FormatObject result with map class definition in context:
[
{
Key #1: Value 1 1
Key #2: Value 2 1
}
]
Add a map object created for the map class definition with no keys
Verify you can format, marshall, and unmarshall an object that references a map
class without any keys defined:
FormatObject Result:
[
{
Key #1: Value 1 1
Key #2: Value 2 1
}
{
}
]
Marshalled String:
@SDT/*:525:@SDT/{:375::13:map-class-map@SDT/{:347::30:STAF/Test/MyMapClassDefini
tion@SDT/{:191::4:keys@SDT/[2:124:@SDT/{:52::12:display-name@SDT/$S:6:Key #1:3:k
ey@SDT/$S:4:key1@SDT/{:52::12:display-name@SDT/$S:6:Key #2:3:key@SDT/$S:4:key2:4
:name@SDT/$S:30:STAF/Test/MyMapClassDefinition:31:STAF/Test/MyMapClassDefinition
2@SDT/{:66::4:keys@SDT/[0:0::4:name@SDT/$S:31:STAF/Test/MyMapClassDefinition2@SD
T/[2:127:@SDT/%:72::30:STAF/Test/MyMapClassDefinition@SDT/$S:9:Value 1 1@SDT/$S:
9:Value 2 1@SDT/%:35::31:STAF/Test/MyMapClassDefinition2
Length of marshalled data: 536
Unmarshall and call FormatObject on the context:
[
{
Key #1: Value 1 1
Key #2: Value 2 1
}
{
}
]
Verify you can format, marshall, and unmarshall an object that references a map
class without a key that it doesn't provide an entry for:
FormatObject Result:
[
{
Key #1: Value 1 1
Key #2: Value 2 1
}
{
Key YYY: <None>
Key XXX: ValueXXX
}
]
Marshalled String:
@SDT/*:686:@SDT/{:508::13:map-class-map@SDT/{:480::30:STAF/Test/MyMapClassDefini
tion@SDT/{:191::4:keys@SDT/[2:124:@SDT/{:52::12:display-name@SDT/$S:6:Key #1:3:k
ey@SDT/$S:4:key1@SDT/{:52::12:display-name@SDT/$S:6:Key #2:3:key@SDT/$S:4:key2:4
:name@SDT/$S:30:STAF/Test/MyMapClassDefinition:31:STAF/Test/MyMapClassDefinition
2@SDT/{:198::4:keys@SDT/[2:130:@SDT/{:55::12:display-name@SDT/$S:7:Key YYY:3:key
@SDT/$S:6:KeyYYY@SDT/{:55::12:display-name@SDT/$S:7:Key XXX:3:key@SDT/$S:6:KeyXX
X:4:name@SDT/$S:31:STAF/Test/MyMapClassDefinition2@SDT/[2:155:@SDT/%:72::30:STAF
/Test/MyMapClassDefinition@SDT/$S:9:Value 1 1@SDT/$S:9:Value 2 1@SDT/%:63::31:ST
AF/Test/MyMapClassDefinition2@SDT/$0:0:@SDT/$S:8:ValueXXX
Length of marshalled data: 697
Unmarshall and call FormatObject on the context:
[
{
Key #1: Value 1 1
Key #2: Value 2 1
}
{
Key YYY: <None>
Key XXX: ValueXXX
}
]
**************************************************************
Test Performance for Marshalling, FormatObject, and Unmarshall
**************************************************************
Test using a list with 100000 entries
FormatObject started: 2006-10-05 at 05:10:50 PM
FormatObject ended : 2006-10-05 at 05:10:50 PM
Marshalling started : 2006-10-05 at 05:10:50 PM
Marshalling ended : 2006-10-05 at 05:10:50 PM
Length of marshalled data: 2888911
Unmarshalling started : 2006-10-05 at 05:10:50 PM
Unmarshalling ended : 2006-10-05 at 05:10:51 PM
Test using a map with 100000 entries
FormatObject started: 2006-10-05 at 05:10:51 PM
FormatObject ended : 2006-10-05 at 05:10:52 PM
Marshalling started : 2006-10-05 at 05:10:52 PM
Marshalling ended : 2006-10-05 at 05:10:52 PM
Length of marshalled data: 3167795
Unmarshalling started : 2006-10-05 at 05:10:52 PM
Unmarshalling ended : 2006-10-05 at 05:10:53 PM
Test using a list with 10000 entries of map class objects with 10 keys
FormatObject started: 2006-10-05 at 05:10:53 PM
FormatObject ended : 2006-10-05 at 05:10:53 PM
Marshalling started : 2006-10-05 at 05:10:53 PM
Marshalling ended : 2006-10-05 at 05:10:54 PM
Length of marshalled data: 2749668
Unmarshalling started : 2006-10-05 at 05:10:54 PM
Unmarshalling ended : 2006-10-05 at 05:10:54 PM
*/
//===========================================================================
import com.ibm.staf.*;
import java.util.*;
import java.text.SimpleDateFormat;
public class MarshallingPerfTest
{
public static SimpleDateFormat formatter = new SimpleDateFormat(
"yyyy-MM-dd 'at' hh:mm:ss a");
public static void main(String [] argv)
{
// Verify the command line arguments
if (argv.length != 1)
{
System.out.println();
System.out.println("Usage: java MarshallingPerfTest <number>");
System.exit(1);
}
int entries = Integer.parseInt(argv[0]);
testErrors(1);
System.out.println(
"\n**************************************************************\n" +
"Test Performance for Marshalling, FormatObject, and Unmarshall\n" +
"**************************************************************");
// Test using a list with the specified number of entries
System.out.println("\nTest using a list with " + entries +
" entries\n");
List myList = new ArrayList();
for (int i = 0; i < entries; i++)
{
myList.add("entryValue ##" + i);
}
STAFMarshallingContext mc = new STAFMarshallingContext();
mc.setRootObject(myList);
System.out.println("FormatObject started: " + formatter.format(new Date()));
STAFMarshallingContext.formatObject(mc);
System.out.println("FormatObject ended : " + formatter.format(new Date()));
String startTime = formatter.format(new Date());
System.out.println("Marshalling started : " + startTime);
String result = mc.marshall();
String endTime = formatter.format(new Date());
System.out.println("Marshalling ended : " + endTime);
System.out.println("Length of marshalled data: " + result.length());
startTime = formatter.format(new Date());
System.out.println("Unmarshalling started : " + startTime);
mc = STAFMarshallingContext.unmarshall(result);
endTime = formatter.format(new Date());
System.out.println("Unmarshalling ended : " + endTime);
myList = new ArrayList();
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -