2 // Copyright (c) 2018 Stefan Seefeld
3 // All rights reserved.
5 // This file is part of Boost.uBLAS. It is made available under the
6 // Boost Software License, Version 1.0.
7 // (Consult LICENSE or http://www.boost.org/LICENSE_1_0.txt)
18 namespace boost { namespace numeric { namespace ublas { namespace benchmark {
22 using clock = std::chrono::system_clock;
24 benchmark(std::string const &name) : name_(name) {}
27 std::cout << "# benchmark : " << name_ << '\n'
28 << "# size \ttime (ms)" << std::endl;
30 virtual void setup(long) {}
31 virtual void operation(long) {}
32 virtual void teardown() {}
34 void run(std::vector<long> const &sizes, unsigned times = 10)
40 auto start = clock::now();
41 for (unsigned i = 0; i != times; ++i)
43 auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(clock::now() - start);
45 std::cout << s << '\t' << duration.count()*1./times << std::endl;