xref: /aosp_15_r20/external/angle/build/util/lib/proto/count.py (revision 8975f5c5ed3d1c378011245431ada316dfb6f244)
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""" A metric implementation to count the number of inputs. """
7
8from measure import Measure
9from test_script_metrics_pb2 import TestScriptMetric
10
11
12class Count(Measure):
13
14  def __init__(self, name: str) -> None:
15    self._name = name
16    self._count = 0
17
18  def record(self) -> None:
19    self._count += 1
20
21  def dump(self) -> TestScriptMetric:
22    result = TestScriptMetric()
23    result.name = self._name
24    result.value = self._count
25    return result
26