Exemplo n.º 1
0
    def encode(self):
        parts = []
        if self.benchmark_start_time_us is not None:
            writer = encoder.Int64Encoder(1, False, False)
            writer(parts.append, self.benchmark_start_time_us)
        if self.story_run_time_us is not None:
            writer = encoder.Int64Encoder(2, False, False)
            writer(parts.append, self.story_run_time_us)
        if self.benchmark_name is not None:
            writer = encoder.StringEncoder(3, False, False)
            writer(parts.append, self.benchmark_name)
        if self.benchmark_description is not None:
            writer = encoder.StringEncoder(4, False, False)
            writer(parts.append, self.benchmark_description)
        if self.label is not None:
            writer = encoder.StringEncoder(5, False, False)
            writer(parts.append, self.label)
        if self.story_name is not None:
            writer = encoder.StringEncoder(6, False, False)
            writer(parts.append, self.story_name)
        if self.story_tags is not None:
            writer = encoder.StringEncoder(7,
                                           is_repeated=True,
                                           is_packed=False)
            writer(parts.append, self.story_tags)
        if self.story_run_index is not None:
            writer = encoder.Int32Encoder(8, False, False)
            writer(parts.append, self.story_run_index)
        if self.had_failures is not None:
            writer = encoder.BoolEncoder(9, False, False)
            writer(parts.append, self.had_failures)

        return b"".join(parts)
Exemplo n.º 2
0
    def encode(self):
        parts = []
        if self.timestamp_delta_us is not None:
            writer = encoder.Int64Encoder(1, False, False)
            writer(parts.append, self.timestamp_delta_us)
        if self.category_iids is not None:
            writer = encoder.UInt32Encoder(3,
                                           is_repeated=True,
                                           is_packed=False)
            writer(parts.append, self.category_iids)
        for annotation in self.debug_annotations:
            tag = encoder.TagBytes(4, wire_format.WIRETYPE_LENGTH_DELIMITED)
            data = annotation.encode()
            length = encoder._VarintBytes(len(data))
            parts += [tag, length, data]
        if self.legacy_event is not None:
            tag = encoder.TagBytes(6, wire_format.WIRETYPE_LENGTH_DELIMITED)
            data = self.legacy_event.encode()
            length = encoder._VarintBytes(len(data))
            parts += [tag, length, data]
        if self.timestamp_absolute_us is not None:
            writer = encoder.Int64Encoder(16, False, False)
            writer(parts.append, self.timestamp_absolute_us)

        return b"".join(parts)
Exemplo n.º 3
0
    def encode(self):
        if (self.pid is None or self.tid is None
                or self.reference_timestamp_us is None):
            raise RuntimeError("Missing mandatory fields.")

        parts = []
        writer = encoder.UInt32Encoder(1, False, False)
        writer(parts.append, self.pid)
        writer = encoder.UInt32Encoder(2, False, False)
        writer(parts.append, self.tid)
        writer = encoder.Int64Encoder(6, False, False)
        writer(parts.append, self.reference_timestamp_us)

        return b"".join(parts)
Exemplo n.º 4
0
    def encode(self):
        if self.name is None:
            raise RuntimeError("DebugAnnotation must have a name.")
        if ((self.string_value is not None) + (self.int_value is not None) +
            (self.double_value is not None)) != 1:
            raise RuntimeError("DebugAnnotation must have exactly one value.")

        parts = []
        writer = encoder.StringEncoder(10, False, False)
        writer(parts.append, self.name)
        if self.int_value is not None:
            writer = encoder.Int64Encoder(4, False, False)
            writer(parts.append, self.int_value)
        if self.double_value is not None:
            writer = encoder.DoubleEncoder(5, False, False)
            writer(parts.append, self.double_value)
        if self.string_value is not None:
            writer = encoder.StringEncoder(6, False, False)
            writer(parts.append, self.string_value)

        return b"".join(parts)