Skip to content

Commit fecbfb8

Browse files
committed
Adding logic to test model construction runtime
1 parent 9048de8 commit fecbfb8

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed

test/aml_comparisons/coek/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ if (${with_gprof})
3535
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
3636
endif()
3737

38+
# coek_build
39+
add_executable(coek_build build.cpp ${sources})
40+
TARGET_LINK_LIBRARIES(coek_build PRIVATE coek::coek)
41+
if (${with_gprof})
42+
target_compile_options(coek_build PUBLIC "-pg")
43+
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
44+
endif()
45+
3846
# coek_solver0
3947
add_executable(coek_solve0 solve0.cpp ${sources})
4048
TARGET_LINK_LIBRARIES(coek_solve0 PRIVATE coek::coek)
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#include <iostream>
2+
#include <string>
3+
#include <vector>
4+
5+
#include "models/coek_models.hpp"
6+
7+
void print_help()
8+
{
9+
std::cout << "coek_build [-d] <model> [<data> ...]" << std::endl;
10+
std::cout << std::endl << "TEST MODELS" << std::endl;
11+
print_models(std::cout);
12+
std::cout << std::endl;
13+
}
14+
15+
int main(int argc, char* argv[])
16+
{
17+
if (argc <= 2) {
18+
print_help();
19+
return 1;
20+
}
21+
22+
bool debug = false;
23+
std::string model_name;
24+
std::vector<size_t> data;
25+
26+
std::vector<std::string> args(argv + 1, argv + argc);
27+
28+
// Loop over command-line args
29+
size_t i = 0;
30+
while (i < args.size()) {
31+
if (args[i] == "-h" || args[i] == "--help") {
32+
print_help();
33+
return 0;
34+
}
35+
else if (args[i] == "-d") {
36+
debug = true;
37+
i++;
38+
}
39+
else {
40+
model_name = args[i++];
41+
while (i < args.size())
42+
data.push_back(std::stoul(args[i++]));
43+
}
44+
}
45+
46+
if (debug)
47+
std::cout << " Model: " << model_name << " Data: " << data[0]
48+
<< std::endl;
49+
coek::Model model;
50+
try {
51+
create_instance(model, model_name, data);
52+
}
53+
catch (std::exception& e) {
54+
std::cout << "ERROR - " << e.what() << std::endl;
55+
return 1;
56+
}
57+
58+
#ifdef COEK_WITH_COMPACT_MODEL
59+
coek::CompactModel cmodel;
60+
try {
61+
create_instance(cmodel, model_name, data);
62+
}
63+
catch (std::exception& e) {
64+
std::cout << "ERROR - " << e.what() << std::endl;
65+
return 1;
66+
}
67+
#endif
68+
69+
std::cout << "coek_build - DONE" << std::endl;
70+
return 0;
71+
}

0 commit comments

Comments
 (0)