|
|
@ -1,5 +1,6 @@
|
|
|
|
// Let Catch provide main():
|
|
|
|
// Let Catch provide main():
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
#define CATCH_CONFIG_MAIN
|
|
|
|
|
|
|
|
#define CATCH_CONFIG_ENABLE_BENCHMARKING
|
|
|
|
|
|
|
|
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
#include <catch2/catch.hpp>
|
|
|
|
|
|
|
|
|
|
|
@ -17,6 +18,20 @@ std::vector<int> generate_random_numbers(int n, int min, int max)
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE( "Simple test" ) {
|
|
|
|
TEST_CASE( "Simple test" ) {
|
|
|
|
std::vector<int> v = { 1, 2, 3, 1};
|
|
|
|
std::vector<int> v = { 1, 2, 3, 1};
|
|
|
|
int r = performance_measuring::compute(v);
|
|
|
|
REQUIRE( performance_measuring::min_element_and_count(v) == 2 );
|
|
|
|
REQUIRE( r == 2 );
|
|
|
|
REQUIRE( performance_measuring::sort_and_upper_bound(v) == 2 );
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
TEST_CASE("Benchmarking") {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::vector<int> v = generate_random_numbers(10000, 0, 1000);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BENCHMARK("min_element_and_count 10k") {
|
|
|
|
|
|
|
|
return performance_measuring::min_element_and_count(v);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
BENCHMARK("sort_and_upper_bound 10k") {
|
|
|
|
|
|
|
|
return performance_measuring::sort_and_upper_bound(v);
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|