Performance
The reason for using the parallel STL is performance. Here are the first numbers.
1
// parallelSTLPerformance.cpp
2
3
#include
<algorithm>
4
#include
<cmath>
5
#include
<chrono>
6
#include
<execution>
7
#include
<iostream>
8
#include
<random>
9
#include
<string>
10
#include
<vector>
11
12
constexpr
long
long
size
=
500
'
000
'
000
;
13
14
const
double
pi
=
std
::
acos
(
-
1
);
15
16
template
<
typename
Func
>
17
void
getExecutionTime
(
const
std
::
string
&
title
,
Func
func
){
18
19
const
auto
sta
=
std
::
chrono
::
steady_clock
::
now
();
20
func
();
21
const
std
::
chrono
::
duration
<
double
>
dur
=
std
::
chrono
::
steady_clock
::
now
()
-
st
\
22
a
;
23
std
::
cout
<<
title
<<
": "
<<
dur
.
count
()
<<
" sec. "
<<
std
::
endl
;
24
25
}
26
27
int
main
(){
28
29
std
::
cout
<<
std
::
endl
;
...