1#!/usr/bin/env vpython3 2 3# Copyright 2024 The Chromium Authors 4# Use of this source code is governed by a BSD-style license that can be 5# found in the LICENSE file. 6""" The entry of the metric system.""" 7 8from measure import Measure 9from test_script_metrics_pb2 import TestScriptMetrics 10 11 12class Metric: 13 14 def __init__(self) -> None: 15 self._metrics: List[Measure] = [] 16 17 def register(self, metric: Measure) -> None: 18 self._metrics.append(metric) 19 20 # Dumping to the protobuf is mostly for testing purpose only. The real use 21 # case would dump everything into a json file for the further upload. 22 # TODO(crbug.com/343242386): May dump to a file once the file name is defined. 23 def dump(self) -> TestScriptMetrics: 24 result = TestScriptMetrics() 25 result.metrics.extend([m.dump() for m in self._metrics]) 26 return result 27