Search in sources :

Example 1 with ProtobufToPig

use of com.twitter.elephantbird.pig.util.ProtobufToPig 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());
}
Also used : ProtobufToPig(com.twitter.elephantbird.pig.util.ProtobufToPig) ProtobufTuple(com.twitter.elephantbird.pig.util.ProtobufTuple) Person(com.twitter.data.proto.tutorial.AddressBookProtos.Person) ProtobufTuple(com.twitter.elephantbird.pig.util.ProtobufTuple) Tuple(org.apache.pig.data.Tuple) StopWatch(org.apache.commons.lang.time.StopWatch)

Aggregations

Person (com.twitter.data.proto.tutorial.AddressBookProtos.Person)1 ProtobufToPig (com.twitter.elephantbird.pig.util.ProtobufToPig)1 ProtobufTuple (com.twitter.elephantbird.pig.util.ProtobufTuple)1 StopWatch (org.apache.commons.lang.time.StopWatch)1 Tuple (org.apache.pig.data.Tuple)1