コード例 #1
0
  def test_checkpoint_add_read_duration(self):
    self.assertEqual(
        self._get_histogram_proto(
            metrics.GetCheckpointReadDurations(api_label="bar")).num, 0)

    metrics.AddCheckpointReadDuration(api_label="bar", microseconds=200)
    metrics.AddCheckpointReadDuration(api_label="bar", microseconds=20000)

    self.assertEqual(
        self._get_histogram_proto(
            metrics.GetCheckpointReadDurations(api_label="bar")).num, 2)
    self.assertEqual(
        self._get_histogram_proto(
            metrics.GetCheckpointReadDurations(api_label="bar")).min, 200)
    self.assertEqual(
        self._get_histogram_proto(
            metrics.GetCheckpointReadDurations(api_label="bar")).max, 20000)
コード例 #2
0
 def _get_read_histogram_proto(self, api_label):
   proto_bytes = metrics.GetCheckpointReadDurations(api_label=api_label)
   histogram_proto = summary_pb2.HistogramProto()
   histogram_proto.ParseFromString(proto_bytes)
   return histogram_proto