Understand the cpu time in multi thread mode

65 views
Skip to first unread message

zhihui....@gmail.com

unread,
Jul 1, 2019, 8:27:20 PM7/1/19
to benchmark-discuss
suppose I run the BM in the following configuration:

```
BENCHMARK(BM_MutexAccess)->Threads(num_threads)->Iterations(iterations);
```

then I got the result

-------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations
-------------------------------------------------------------------------------------------------
BM_RawAccess/iterations:1000000/process_time/threads:4 0.410 ns 0.997 ns 4000000


what I want to know is: what is the avg cpu time of all the iterations.


1. In the comments of the `MeasureProcessCPUTime`, it says

// By default, the CPU time is measured only for the main thread, which may
// be unrepresentative if the benchmark uses threads internally. If called,
// the total CPU time spent by all the threads will be measured instead.
// By default, the only the main thread CPU time will be measured.
Benchmark* MeasureProcessCPUTime();

a). what does the "main thread" means? In my above setup, it needs 4 threads. does it mean it has 4 worker threads and 1 main thread? so what is the pointer of cpu time for "main" thread?

Reply all
Reply to author
Forward
0 new messages