1 #ifndef GINAC_CHECK_TEST_RUNNER_H
2 #define GINAC_CHECK_TEST_RUNNER_H
9 template<typename T> static void
10 run_benchmark(T& benchmark,
11 const unsigned ntests = 10,
12 const std::clock_t t_annoying = 15*CLOCKS_PER_SEC,
13 const std::clock_t t_min = CLOCKS_PER_SEC/100)
15 const std::clock_t start(std::clock());
16 std::clock_t elapsed(start);
27 go_on = benchmark.check();
30 elapsed = std::clock() - start;
31 if (elapsed > t_annoying)
33 } while (n <= ntests || elapsed < t_min);
35 benchmark.print_result(t);
38 // By default long-running timings are disabled (to not annoy the user).
39 // If the GINAC_RUN_EXPENSIVE_TIMINGS environment variable is set to "1",
40 // some of them (which are supposed to be relatively fast) will be enabled.
41 // If GINAC_RUN_EXPENSIVE_TIMINGS is set to "2", all timings are enabled.
42 static int run_expensive_timings_p()
46 static const std::string env_name("GINAC_RUN_EXPENSIVE_TIMINGS");
48 char* envvar = std::getenv(env_name.c_str());
50 value = std::atoi(envvar);
51 if (value < 0 || value > 2)
55 std::cerr << "WARNING: "
56 << "long-running timings are ENABLED."
58 << "Unset the \"" << env_name << "\" "
59 << "environment variable skip them."
66 #endif // GINAC_CHECK_TEST_RUNNER_H