本文整理汇总了C++中Metric::update方法的典型用法代码示例。如果您正苦于以下问题:C++ Metric::update方法的具体用法?C++ Metric::update怎么用?C++ Metric::update使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Metric
的用法示例。
在下文中一共展示了Metric::update方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: catch
TEST_F(HIST_PERC_Fixture,TestPercentilesMany)
{
bool failure = false;
try {
factory->process("create percentiles aaa with time_window=30 collect_period=10 ps=50:90:99:99.9");
}
catch(std::runtime_error& ex) {
cout << "Failed: " << ex.what() << endl;
failure = true;
}
catch(...) {
failure = true;
}
ASSERT_FALSE(failure);
Dataset* dataset = Dataset::open(path, CWSE_DATA_ACCESS_READ_ONLY);
try {
uint16_t ids[4];
ids[0] = dataset->findColumn("aaa.50");
ids[1] = dataset->findColumn("aaa.90");
ids[2] = dataset->findColumn("aaa.99");
ids[3] = dataset->findColumn("aaa.99.9");
for (int i=0; i < 4; i++) {
ASSERT_TRUE(ids[i] != CWSE_INVALID_COLUMN_ID);
ASSERT_EQ(0, dataset->get(ids[i]));
}
Metric* metric = factory->find("aaa");
ASSERT_FALSE(metric == NULL);
Percentiles* p = dynamic_cast<Percentiles*>(metric);
ASSERT_FALSE(p == NULL);
p->resetNextTimePoint(10);
for (int i=1; i <= 100; i++) {
metric->update(i);
}
p->onTimeTick(10);
ASSERT_EQ(50.5, dataset->get(ids[0]));
ASSERT_EQ(90.5, dataset->get(ids[1]));
ASSERT_EQ(99.5, dataset->get(ids[2]));
ASSERT_EQ(100, dataset->get(ids[3]));
}
catch(std::runtime_error& ex) {
cout << "Failed: " << ex.what() << endl;
failure = true;
}
catch(...) {
delete dataset;
ASSERT_TRUE(false);
}
delete dataset;
}