diff options
| author | Christoph Berg <myon@debian.org> | 2020-05-11 22:18:20 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2020-05-11 22:18:20 +0200 |
| commit | a8edac06b534058e52126c4d55e23b217df2df91 (patch) | |
| tree | f2c3567fae58aad676d544ee8f07ac78dd2eb1ec /boost/libs/math/reporting/performance/performance.hpp | |
| parent | 4f6c0156a70e8f2ff70fe5a1a39f5e9b22ffd026 (diff) | |
| parent | 32a41b1abe1a4aab0892c9c2051be6ba5b379f1e (diff) | |
Update upstream source from tag 'upstream/2.2.0_rc1+repack'
Update to upstream version '2.2.0~rc1+repack'
with Debian dir fe177bc6cd2d4c1256a3775504f6010be54e7463
Diffstat (limited to 'boost/libs/math/reporting/performance/performance.hpp')
| -rw-r--r-- | boost/libs/math/reporting/performance/performance.hpp | 115 |
1 files changed, 0 insertions, 115 deletions
diff --git a/boost/libs/math/reporting/performance/performance.hpp b/boost/libs/math/reporting/performance/performance.hpp deleted file mode 100644 index e52fd5c5..00000000 --- a/boost/libs/math/reporting/performance/performance.hpp +++ /dev/null @@ -1,115 +0,0 @@ -// Copyright John Maddock 2015. -// Use, modification and distribution are subject to the -// Boost Software License, Version 1.0. (See accompanying file -// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - -#ifndef PERFORMANCE_HPP -#define PERFORMANCE_HPP - -#include <boost/math/special_functions/relative_difference.hpp> -#include <boost/array.hpp> -#include <boost/chrono.hpp> -#include <boost/regex.hpp> - -template <class Array> -void add_data(const Array& a) -{ - // - // This function is called multiple times to merge multiple data sets into one big table: - // - for(typename Array::const_iterator i = a.begin(); i != a.end(); ++i) - { - data.push_back(std::vector<double>()); - for(typename Array::value_type::const_iterator j = i->begin(); j != i->end(); ++j) - { - data.back().push_back(*j); - } - } -} - -template <class Func, class Result> -void screen_data(Func f, Result r) -{ - // - // If any of the implementations being tested produces garbage for one of our - // test cases (or else if we test a domain they don't support), then we remove that - // row from the table. This allows us to only test a common supported sub-set for performance: - // - for(std::vector<std::vector<double> >::size_type row = 0; row < data.size(); ++row) - { - try - { - double computed = f(data[row]); - double expected = r(data[row]); - double err = boost::math::relative_difference(computed, expected); - if(err > 1e-7) - { - std::cout << "Erasing row: "; - for(unsigned i = 0; i < data[row].size(); ++i) - { - std::cout << data[row][i] << " "; - } - std::cout << "Error was " << err << std::endl; - data.erase(data.begin() + row); - --row; - } - } - catch(const std::exception& e) - { - std::cout << "Erasing row: "; - for(unsigned i = 0; i < data[row].size(); ++i) - { - std::cout << data[row][i] << " "; - } - std::cout << "due to thrown exception: " << e.what() << std::endl; - data.erase(data.begin() + row); - --row; - } - } -} - -template <class Clock> -struct stopwatch -{ - typedef typename Clock::duration duration; - stopwatch() - { - m_start = Clock::now(); - } - duration elapsed() - { - return Clock::now() - m_start; - } - void reset() - { - m_start = Clock::now(); - } - -private: - typename Clock::time_point m_start; -}; - -double sum = 0; - -template <class Func> -double exec_timed_test(Func f) -{ - double t = 0; - unsigned repeats = 1; - do{ - stopwatch<boost::chrono::high_resolution_clock> w; - - for(unsigned count = 0; count < repeats; ++count) - { - for(std::vector<std::vector<double> >::const_iterator i = data.begin(); i != data.end(); ++i) - sum += f(*i); - } - - t = boost::chrono::duration_cast<boost::chrono::duration<double>>(w.elapsed()).count(); - if(t < 0.5) - repeats *= 2; - } while(t < 0.5); - return t / (repeats * data.size()); -} - -#endif // PERFORMANCE_HPP |
