• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 module to create and manage measures using in the process. """
7
8from typing import Iterable
9
10from average import Average
11from count import Count
12from data_points import DataPoints
13from measure import Measure
14from metric import Metric
15
16_metric = Metric()
17
18
19def _create_name(*name_pieces: str) -> str:
20  if len(name_pieces) == 0:
21    raise ValueError('Need at least one name piece.')
22  return '/'.join(list(name_pieces))
23
24
25def _register(m: Measure) -> Measure:
26  _metric.register(m)
27  return m
28
29
30def average(*name_pieces: str) -> Average:
31  return _register(Average(_create_name(*name_pieces)))
32
33
34def count(*name_pieces: str) -> Count:
35  return _register(Count(_create_name(*name_pieces)))
36
37
38def data_points(*name_pieces: str) -> DataPoints:
39  return _register(DataPoints(_create_name(*name_pieces)))
40