MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / TEST

Function TEST

tensorflow/core/lib/monitoring/collection_registry_test.cc:45–67  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

43void EmptyCollectionFunction(MetricCollectorGetter getter) {}
44
45TEST(CollectionRegistryTest, RegistrationUnregistration) {
46 auto* collection_registry = CollectionRegistry::Default();
47 const MetricDef<MetricKind::kCumulative, int64, 0> metric_def0(
48 "/tensorflow/metric0", "An example metric with no labels.");
49 const MetricDef<MetricKind::kGauge, HistogramProto, 1> metric_def1(
50 "/tensorflow/metric1", "An example metric with one label.", "LabelName");
51
52 {
53 // Enclosed in a scope so that we unregister before the stack variables
54 // above are destroyed.
55
56 std::unique_ptr<CollectionRegistry::RegistrationHandle> handle0 =
57 collection_registry->Register(&metric_def0, EmptyCollectionFunction);
58 std::unique_ptr<CollectionRegistry::RegistrationHandle> handle1 =
59 collection_registry->Register(&metric_def1, EmptyCollectionFunction);
60
61 handle0.reset();
62
63 // Able to register again because it was unregistered earlier.
64 handle0 =
65 collection_registry->Register(&metric_def0, EmptyCollectionFunction);
66 }
67}
68
69TEST(CollectionRegistryDeathTest, DuplicateRegistration) {
70 auto* collection_registry = CollectionRegistry::Default();

Callers

nothing calls this directly

Calls 15

DefaultFunction · 0.85
CollectMetricsMethod · 0.80
CollectValueMethod · 0.80
EqHistogramsFunction · 0.70
StrCatFunction · 0.50
RegisterMethod · 0.45
resetMethod · 0.45
IncrementByMethod · 0.45
GetCellMethod · 0.45
sizeMethod · 0.45
atMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected