Skip to content

Commit

Permalink
add header to timing data output by --osh-time[-percent] (#91)
Browse files Browse the repository at this point in the history
- add header to timing data output by --osh-time[-percent]
- tests that exercise --osh-time[-percent] [--osh-time-chop ##]
- better help string for --osh-time-chop ##
  • Loading branch information
cwsmith authored Mar 8, 2024
1 parent 630e4ed commit 6216b3a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,10 @@ if(BUILD_TESTING)
osh_add_exe(osh_scale2d)
set(TEST_EXES ${TEST_EXES} osh_scale2d)
test_func(osh_scale2d 1 ./osh_scale2d ${CMAKE_SOURCE_DIR}/meshes/plate_6elem.osh 100 plate_100.osh)
set(scale2dArgs ${CMAKE_SOURCE_DIR}/meshes/plate_6elem.osh 100 plate_100.osh)
test_func(osh_scale2d_time 1 ./osh_scale2d --osh-time ${scale2dArgs})
test_func(osh_scale2d_timepercent 1 ./osh_scale2d --osh-time-percent ${scale2dArgs})
test_func(osh_scale2d_timechop 1 ./osh_scale2d --osh-time --osh-time-chop 10 ${scale2dArgs})

test_basefunc(run_arrayops 1 ./arrayops_test)
set(TEST_EXES ${TEST_EXES} reprosum_test)
Expand Down
2 changes: 1 addition & 1 deletion src/Omega_h_library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void Library::initialize(char const* head_desc, int* argc, char*** argv
cmdline.add_flag(
"--osh-time-percent", "print amount of time spend in certain functions by percentage");
auto& osh_time_chop_flag = cmdline.add_flag(
"--osh-time-chop", "only print functions whose percent time is greater than given value (e.g. --osh-time-chop=2)");
"--osh-time-chop", "only print functions whose percent time is greater than given value (e.g. --osh-time[-percent] --osh-time-chop 2)");
osh_time_chop_flag.add_arg<double>("0.0");
cmdline.add_flag("--osh-time-with-filename", "add file name to function name in profile output");

Expand Down
8 changes: 6 additions & 2 deletions src/Omega_h_profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,17 @@ void print_top_down_and_bottom_up(History const& h, double total_runtime) {
if (h.do_percent) {
std::cout << std::setprecision(2) << std::fixed;
}
std::stringstream header;
header << "(function_name time("
<< (h.do_percent ? "% total time" : "seconds")
<< ") number_of_calls)";
std::cout << "\n";
std::cout << "TOP-DOWN:\n";
std::cout << "TOP-DOWN " << header.str() << ":\n";
std::cout << "=========\n";
print_time_sorted(h, total_runtime);
auto h_inv = invert(h);
std::cout << "\n";
std::cout << "BOTTOM-UP:\n";
std::cout << "BOTTOM-UP " << header.str() << ":\n";
std::cout << "==========\n";
print_time_sorted(h_inv, total_runtime);
std::cout.flags(coutflags);
Expand Down

0 comments on commit 6216b3a

Please sign in to comment.