Skip to content

Commit

Permalink
Update benchmark target to also include serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanoBilenchi committed Nov 19, 2024
1 parent 1fb640a commit fbd89e6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
8 changes: 8 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ add_executable(cowl-bench EXCLUDE_FROM_ALL)
target_sources(cowl-bench PRIVATE "${COWL_TEST_DIR}/bench.c")
target_link_libraries(cowl-bench PRIVATE cowl)

if(COWL_LTO_ENABLED)
set_target_properties(cowl-bench PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if(COWL_CLANG_TIDY)
clang_tidy_check(cowl-bench)
endif()
Expand All @@ -36,6 +40,10 @@ target_sources(cowl-test
target_include_directories(cowl-test PRIVATE ${COWL_PRIVATE_HEADERS_DIRS})
target_link_libraries(cowl-test PRIVATE cowl)

if(COWL_LTO_ENABLED)
set_target_properties(cowl-test PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if(COWL_CLANG_TIDY)
clang_tidy_check(cowl-test)
endif()
Expand Down
20 changes: 15 additions & 5 deletions test/bench.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ int main(int argc, char *argv[]) {
cowl_init();

char const *path = argc > 1 ? argv[1] : "test_onto.owl";
char const *out_path = argc > 2 ? argv[2] : "test_out.owl";

CowlManager *manager = cowl_manager();

utime_ns t = utime_get_ns();
CowlOntology *onto = cowl_manager_read_path(manager, ustring_wrap_buf(path));
t = utime_get_ns() - t;

cowl_release(manager);

if (!onto) {
printf("Failed to read ontology at path: %s", path);
printf("Failed to read ontology at path: %s\n", path);
return EXIT_FAILURE;
}

printf("Ontology parsed in %.2f ms\n", utime_interval_convert(t, UTIME_MILLISECONDS));
printf("Ontology read in %.2f ms\n", utime_interval_convert(t, UTIME_MILLISECONDS));

ulib_uint count = 0;
CowlIterator iter = { &count, count_constructs };
Expand All @@ -56,7 +56,17 @@ int main(int argc, char *argv[]) {
printf("%" ULIB_UINT_FMT " primitives iterated in %.2f us\n", count,
utime_interval_convert(t, UTIME_MICROSECONDS));

cowl_release(onto);
t = utime_get_ns();
cowl_ret ret = cowl_manager_write_path(manager, onto, ustring_wrap_buf(out_path));
t = utime_get_ns() - t;

if (ret) {
printf("Failed to write ontology at path: %s\n", out_path);
} else {
printf("Ontology written in %.2f ms\n", utime_interval_convert(t, UTIME_MILLISECONDS));
}

cowl_release_all(manager, onto);

return EXIT_SUCCESS;
}
4 changes: 4 additions & 0 deletions tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ target_sources(cowl-stats PRIVATE "${COWL_TOOLS_DIR}/stats.c")
target_link_libraries(cowl-stats PRIVATE cowl)
add_dependencies(cowl-tools cowl-stats)

if(COWL_LTO_ENABLED)
set_target_properties(cowl-stats PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

if(COWL_CLANG_TIDY)
clang_tidy_check(cowl-stats)
endif()

0 comments on commit fbd89e6

Please sign in to comment.