use of org.apache.commons.lang.time.StopWatch in project elephant-bird by twitter.
the class TimeProtoConversions method main.
/**
* @param args
* @throws ExecException
*/
public static void main(String[] args) throws ExecException {
int iterations = 100000;
ProtobufToPig protoConv = new ProtobufToPig();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = protoConv.toTuple(proto);
t.get(0);
t = new ProtobufTuple(proto);
t.get(0);
}
StopWatch timer = new StopWatch();
timer.start();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = protoConv.toTuple(proto);
t.get(0);
}
timer.split();
System.err.println(timer.getSplitTime());
timer.reset();
timer.start();
for (int i = 0; i < iterations; i++) {
Person proto = Fixtures.buildPersonProto();
Tuple t = new ProtobufTuple(proto);
t.get(0);
}
timer.split();
System.err.println(timer.getSplitTime());
}
use of org.apache.commons.lang.time.StopWatch in project simplejpa by appoxy.
the class PerformanceTests method testPutQueryDelete.
@Test
public void testPutQueryDelete() throws ExecutionException, InterruptedException {
int numItems = 1;
String x;
EntityManagerSimpleJPA em = (EntityManagerSimpleJPA) factory.createEntityManager();
PerformanceTestObject o = new PerformanceTestObject();
o.setS1("first to create domain");
em.persist(o);
StopWatch stopWatch = new StopWatch();
String s1a = "attribute1";
String s2a = "attribute2";
Future<PerformanceTestObject> lastFuture = null;
stopWatch.start();
for (int i = 0; i < numItems; i++) {
o = new PerformanceTestObject();
o.setS1(s1a);
o.setS2(s2a);
lastFuture = em.persistAsync(o);
}
// not 100% accurate, but good enough
lastFuture.get();
stopWatch.stop();
System.out.println("puts duration=" + stopWatch.getTime() + ", " + em.getTotalOpStats().getPuts() + " items put.");
Thread.sleep(5000);
stopWatch.reset();
stopWatch.start();
Query query = em.createQuery("select o from PerformanceTestObject o");
List<PerformanceTestObject> resultList = query.getResultList();
System.out.println("iterating result list...");
int i = 0;
for (PerformanceTestObject performanceTestObject : resultList) {
i++;
if (i % 100 == 0) {
System.out.println(i);
}
}
stopWatch.stop();
System.out.println("query ALL duration=" + stopWatch.getTime() + ", " + em.getTotalOpStats().getGets() + " items got.");
stopWatch.reset();
stopWatch.start();
System.out.println("Deleting ALL...");
for (PerformanceTestObject performanceTestObject : resultList) {
lastFuture = em.removeAsync(o);
}
lastFuture.get();
stopWatch.stop();
System.out.println("delete duration=" + stopWatch.getTime() + ", " + resultList.size() + " items deleted.");
System.out.println("sleeping...");
Thread.sleep(30000);
em.close();
}
use of org.apache.commons.lang.time.StopWatch in project fastjson by alibaba.
the class TestFastJson method testDeserializePerformance.
public void testDeserializePerformance() throws IOException, ClassNotFoundException {
Object obj = createTest();
byte[] bytes = JSON.toJSONBytes(obj, SerializerFeature.WriteClassName);
ByteArrayOutputStream os = new ByteArrayOutputStream();
ObjectOutputStream oos = new ObjectOutputStream(os);
oos.writeObject(obj);
byte[] javaBytes = os.toByteArray();
System.out.println(bytes.length);
for (int x = 0; x < 20; ++x) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
// ByteArrayInputStream is = new ByteArrayInputStream(bytes);
Object o = jsonDeserialize(bytes, GenericRS.class);
o.getClass();
}
stopWatch.stop();
System.out.println("JSON deserialize:" + stopWatch.getTime());
stopWatch.reset();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
Object o = javaDeserialize(javaBytes);
o.getClass();
}
stopWatch.stop();
System.out.println("JAVA deserialize:" + stopWatch.getTime());
System.out.println();
}
}
use of org.apache.commons.lang.time.StopWatch in project fastjson by alibaba.
the class TestFastJson method testFP.
public void testFP() throws IOException {
Generic<String> q = new Generic<String>();
for (int x = 0; x < STAYS_COUNT; ++x) {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
jsonSerialize(q);
}
stopWatch.stop();
System.out.println("JSON serialize:" + stopWatch.getTime());
stopWatch.reset();
stopWatch.start();
for (int i = 0; i < TIMES; ++i) {
javaSerialize(q);
}
stopWatch.stop();
System.out.println("JAVA serialize:" + stopWatch.getTime());
System.out.println();
}
}
Aggregations