'Comparing encoding speed of a typical protobuf.'

def testEncode(self):

    s = jobs_pb2.GrrMessage(name=u'foo', request_id=1, response_id=1, session_id=u'session')
    serialized = s.SerializeToString()
    def ProtoEncode():
        s1 = jobs_pb2.GrrMessage(name=u'foo', request_id=1, response_id=1, session_id=u'session')
        test = s1.SerializeToString()
        self.assertEqual(len(serialized), len(test))
    def RDFStructEncode():
        s2 = StructGrrMessage(name=u'foo', request_id=1, response_id=1, session_id=u'session')
        test = s2.SerializeToString()
        self.assertEqual(len(serialized), len(test))
    self.TimeIt(RDFStructEncode)
    self.TimeIt(ProtoEncode)
