本文整理汇总了C++中Benchmark::init方法的典型用法代码示例。如果您正苦于以下问题:C++ Benchmark::init方法的具体用法?C++ Benchmark::init怎么用?C++ Benchmark::init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Benchmark
的用法示例。
在下文中一共展示了Benchmark::init方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main (int argc, char *argv[])
{
string prefix;
unsigned K;
float R;
po::options_description desc("Allowed options");
desc.add_options()
("help,h", "produce help message.")
(",K", po::value<unsigned>(&K)->default_value(100), "number of nearest neighbors.")
("prefix,D", po::value<string>(&prefix), "")
("threshold,R", po::value<float>(&R)->default_value(std::numeric_limits<float>::max()), "radius of search.")
;
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
po::notify(vm);
if (vm.count("help") || (vm.count("prefix") < 1))
{
cout << help << endl;
cout << desc;
return 0;
}
Matrix<float> train(prefix + ".train");
Matrix<float> test(prefix + ".test");
Benchmark<unsigned> bench;
bench.init(test.getSize(), test.getSize() * 100);
boost::timer timer;
timer.restart();
metric::l2<float> l2(train.getDim());
boost::progress_display progress(test.getSize());
int totalSize = 0;
for (unsigned i = 0; i < test.getSize(); ++i)
{
Topk<unsigned> &topk = bench.getAnswer(i);
topk.reset(K,R);
for (unsigned j = 0; j < train.getSize(); ++j)
{
topk << Topk<unsigned>::Element(j, l2(test[i],
train[j]));
}
++progress;
totalSize += topk.numElements();
}
cout << boost::format("QUERY TIME: %1%s.") % timer.elapsed() << endl;
cout << "Average List Size: " << float(totalSize)/test.getSize() << endl;
if (R < std::numeric_limits<float>::max())
bench.save(prefix + ".bench-eps");
else
bench.save(prefix + ".bench");
return 0;
}