예제 #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)
예제 #2
0
    def encode(self):
        if self.name is None or self.string_value is None:
            raise RuntimeError("ChromeMetadata must have a name and a value.")

        parts = []
        writer = encoder.StringEncoder(1, False, False)
        writer(parts.append, self.name)
        writer = encoder.StringEncoder(2, False, False)
        writer(parts.append, self.string_value)

        return b"".join(parts)
예제 #3
0
    def encode(self):
        if (self.iid is None or self.name is None):
            raise RuntimeError("Missing mandatory fields.")

        parts = []
        writer = encoder.UInt32Encoder(1, False, False)
        writer(parts.append, self.iid)
        writer = encoder.StringEncoder(2, False, False)
        writer(parts.append, self.name)

        return b"".join(parts)
예제 #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)