mirror of
https://github.com/allemangD/toddcox-visualize.git
synced 2025-11-10 03:52:48 -05:00
Add benchmark tests
This commit is contained in:
@@ -26,3 +26,15 @@ add_simple_test(test_solve H)
|
|||||||
add_simple_test(test_solve I)
|
add_simple_test(test_solve I)
|
||||||
add_simple_test(test_solve T)
|
add_simple_test(test_solve T)
|
||||||
add_simple_test(test_solve X)
|
add_simple_test(test_solve X)
|
||||||
|
|
||||||
|
set(MIN_DEBUG_CPS 300000)
|
||||||
|
set(MIN_RELEASE_CPS 700000)
|
||||||
|
add_executable(test_solve_speed test_solve_speed.cpp)
|
||||||
|
target_link_libraries(test_solve_speed PUBLIC tc)
|
||||||
|
target_compile_definitions(test_solve_speed PUBLIC MINIMUM_COS_PER_SEC=$<IF:$<CONFIG:Debug>,${MIN_DEBUG_CPS},${MIN_RELEASE_CPS}>)
|
||||||
|
add_simple_test(test_solve_speed B)
|
||||||
|
set_tests_properties(test_solve_speed_B PROPERTIES TIMEOUT 45)
|
||||||
|
add_simple_test(test_solve_speed E)
|
||||||
|
set_tests_properties(test_solve_speed_E PROPERTIES TIMEOUT 30)
|
||||||
|
add_simple_test(test_solve_speed T)
|
||||||
|
set_tests_properties(test_solve_speed_T PROPERTIES TIMEOUT 15)
|
||||||
|
|||||||
58
tc/test/test_solve_speed.cpp
Normal file
58
tc/test/test_solve_speed.cpp
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include <tc/groups.hpp>
|
||||||
|
#include <tc/core.hpp>
|
||||||
|
|
||||||
|
int main(int argc, char *argv[]) {
|
||||||
|
std::string key = argv[1];
|
||||||
|
|
||||||
|
std::cerr << "Min. cos/s: " << MINIMUM_COS_PER_SEC << std::endl;
|
||||||
|
std::vector<std::tuple<std::string, tc::Group, std::vector<size_t>, size_t>> groups;
|
||||||
|
|
||||||
|
// See the group orders here https://en.wikipedia.org/wiki/Coxeter_group#Properties
|
||||||
|
if (key == "B") {
|
||||||
|
groups = {
|
||||||
|
{"B(7)", tc::group::B(7), {}, 645120},
|
||||||
|
{"B(8)", tc::group::B(8), {}, 10321920},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (key == "E") {
|
||||||
|
groups = {
|
||||||
|
{"E(6)", tc::group::E(6), {}, 51840},
|
||||||
|
{"E(7)", tc::group::E(7), {}, 2903040},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
if (key == "T") {
|
||||||
|
groups = {
|
||||||
|
{"T(500)", tc::group::T(500), {}, 1000000},
|
||||||
|
{"T(1000)", tc::group::T(1000), {}, 4000000},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
int status = EXIT_SUCCESS;
|
||||||
|
|
||||||
|
for (const auto &[name, group, sub_gens, expected]: groups) {
|
||||||
|
auto t0 = clock();
|
||||||
|
auto cos = tc::solve(group, sub_gens);
|
||||||
|
auto t1 = clock();
|
||||||
|
auto actual = cos.size();
|
||||||
|
|
||||||
|
auto sec = (double) (t1 - t0) / CLOCKS_PER_SEC;
|
||||||
|
auto cos_per_sec = (double) actual / sec;
|
||||||
|
|
||||||
|
if (expected != actual) {
|
||||||
|
std::cerr << name << " wrong. " << actual << " (" << expected << ")" << std::endl;
|
||||||
|
status = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::cout << name << " cos/s: " << (size_t) cos_per_sec << std::endl;
|
||||||
|
if (cos_per_sec < MINIMUM_COS_PER_SEC) {
|
||||||
|
std::cerr << name << " too slow." << std::endl;
|
||||||
|
status = EXIT_FAILURE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user