-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathsort.cpp
More file actions
39 lines (27 loc) · 796 Bytes
/
sort.cpp
File metadata and controls
39 lines (27 loc) · 796 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#include <oneapi/tbb/parallel_sort.h>
#include <oneapi/tbb/tick_count.h>
#include <vector>
#include <print>
using namespace oneapi::tbb;
using namespace std;
const int TESTSIZ = 120 * 3000;
int main(int argc, char const* argv[])
{
srand((unsigned)time(nullptr));
vector<int> vi(TESTSIZ);
for (int i=0; i<TESTSIZ; ++i) vi[i] = rand();
tick_count t0, t1;
for (int i=0; i<10; ++i)
{
vector<int> vi_clone1(vi), vi_clone2(vi);
t0 = tick_count::now();
sort(vi_clone1.begin(), vi_clone1.end());
t1 = tick_count::now();
println("std::sort {} ms", (t1 - t0).seconds());
t0 = tick_count::now();
parallel_sort(vi_clone2.begin(), vi_clone2.end());
t1 = tick_count::now();
println("tbb::parallel_sort {} ms", (t1 - t0).seconds());
}
return 0;
}