Times how long it takes to run num_threads 'executors', each of which spawns num_threads_per_executor empty threads, and to wait for all of them to finish.
| 104 | // which spawns num_threads_per_executor empty threads, and to wait |
| 105 | // for all of them to finish. |
| 106 | void TimeParallelExecutors(int num_threads, int num_threads_per_executor, |
| 107 | bool use_native_threads = true) { |
| 108 | StopWatch sw; |
| 109 | sw.Start(); |
| 110 | if (use_native_threads) { |
| 111 | function<void ()> f = |
| 112 | bind(NativeThreadStarter, num_threads_per_executor, EmptyThread); |
| 113 | NativeThreadStarter(num_threads, f); |
| 114 | } else { |
| 115 | function<void ()> f = |
| 116 | bind(ImpalaThreadStarter, num_threads_per_executor, EmptyThread); |
| 117 | ImpalaThreadStarter(num_threads, f); |
| 118 | } |
| 119 | sw.Stop(); |
| 120 | cout << (use_native_threads ? "(Native):" : "(Impala):") |
| 121 | << "Time to start up " << num_threads << " * " << num_threads_per_executor << " = " |
| 122 | << num_threads * num_threads_per_executor << " threads: " |
| 123 | << PrettyPrinter::Print(sw.ElapsedTime(), TUnit::CPU_TICKS) << endl; |
| 124 | } |
| 125 | |
| 126 | int main(int argc, char **argv) { |
| 127 | google::InitGoogleLogging(argv[0]); |
no test coverage detected