diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-12-09 17:56:55 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-12-09 17:56:55 +0200 |
commit | 2d2cbcaf1c2afd1565502f8f0c83fb1cd56f6cec (patch) | |
tree | a636046cfac3129bfeea27c50bb71e9536cb3108 /unit-tests/scheduler | |
parent | ea22643b2217921df74ea14df47d7c83987d5761 (diff) |
Fix GCC 5 compilation error, improve scheduler unit test
Diffstat (limited to 'unit-tests/scheduler')
-rw-r--r-- | unit-tests/scheduler/driver.cxx | 48 |
1 files changed, 31 insertions, 17 deletions
diff --git a/unit-tests/scheduler/driver.cxx b/unit-tests/scheduler/driver.cxx index 65ba5e5..726415a 100644 --- a/unit-tests/scheduler/driver.cxx +++ b/unit-tests/scheduler/driver.cxx @@ -17,11 +17,24 @@ using namespace std; namespace build2 { + // Usage argv[0] <max-active-threads> + // int - main () + main (int argc, char* argv[]) { - //scheduler s (1); - scheduler s (scheduler::hardware_concurrency ()); + bool verb (false); + size_t max_active (0); + + if (argc > 1) + { + verb = true; + max_active = stoul (argv[1]); + } + + if (max_active == 0) + max_active = scheduler::hardware_concurrency (); + + scheduler s (max_active); auto inner = [] (size_t x, size_t y, size_t& out) { @@ -70,25 +83,26 @@ namespace build2 scheduler::stat st (s.shutdown ()); - /* - cerr << "thread_max_active " << st.thread_max_active << endl - << "thread_max_total " << st.thread_max_total << endl - << "thread_helpers " << st.thread_helpers << endl - << "thread_max_waiting " << st.thread_max_waiting << endl - << endl - << "task_queue_depth " << st.task_queue_depth << endl - << "task_queue_full " << st.task_queue_full << endl - << endl - << "wait_queue_slots " << st.wait_queue_slots << endl - << "wait_queue_collisions " << st.wait_queue_collisions << endl; - */ + if (verb) + { + cerr << "thread_max_active " << st.thread_max_active << endl + << "thread_max_total " << st.thread_max_total << endl + << "thread_helpers " << st.thread_helpers << endl + << "thread_max_waiting " << st.thread_max_waiting << endl + << endl + << "task_queue_depth " << st.task_queue_depth << endl + << "task_queue_full " << st.task_queue_full << endl + << endl + << "wait_queue_slots " << st.wait_queue_slots << endl + << "wait_queue_collisions " << st.wait_queue_collisions << endl; + } return 0; } } int -main () +main (int argc, char* argv[]) { - return build2::main (); + return build2::main (argc, argv); } |