The time you report is measured using the clock function:
The function clock()returns the approximate processor time used by the program.
$ time bin/amit_kumar_threads.cpp
6.62seconds
serial: 2.7seconds
real 0m5.247s
user 0m9.025s
sys 0m0.304s
Real time will be less for multiprocessor tasks, but CPU time will usually be longer.
, , , , , , . clock() , + . .
, , , , clock(), , , , , .
clock_gettime() ( ltime, g++ -lrt ..):
$ time bin/amit_kumar_threads.cpp
2.524 seconds
serial: 2.761 seconds
real 0m5.326s
user 0m9.057s
sys 0m0.344s
- , , , , .
100000000 * 20/2.5s = 800 , 1600 , , ( ), , tstenner, clock() , . (- , clock() ?)