tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

count.py (617B)


      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 
      8 from measure import Measure
      9 from test_script_metrics_pb2 import TestScriptMetric
     10 
     11 
     12 class 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