]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/compute/perf/perf_stl_set_symmetric_difference.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / compute / perf / perf_stl_set_symmetric_difference.cpp
1 //---------------------------------------------------------------------------//
2 // Copyright (c) 2014 Roshan <thisisroshansmail@gmail.com>
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 // See http://boostorg.github.com/compute for more information.
9 //---------------------------------------------------------------------------//
10
11 #include <vector>
12 #include <algorithm>
13 #include <iostream>
14
15 #include "perf.hpp"
16
17 int rand_int()
18 {
19 return static_cast<int>((rand() / double(RAND_MAX)) * 25.0);
20 }
21
22 int main(int argc, char *argv[])
23 {
24 perf_parse_args(argc, argv);
25
26 std::cout << "size: " << PERF_N << std::endl;
27
28 std::vector<int> v1(std::floor(PERF_N / 2.0));
29 std::vector<int> v2(std::ceil(PERF_N / 2.0));
30
31 std::generate(v1.begin(), v1.end(), rand_int);
32 std::generate(v2.begin(), v2.end(), rand_int);
33
34 std::sort(v1.begin(), v1.end());
35 std::sort(v2.begin(), v2.end());
36
37 std::vector<int> v3(PERF_N);
38 std::vector<int>::iterator v3_end;
39
40 perf_timer t;
41 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
42 t.start();
43 v3_end = std::set_symmetric_difference(
44 v1.begin(), v1.end(),
45 v2.begin(), v2.end(),
46 v3.begin()
47 );
48 t.stop();
49 }
50 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
51 std::cout << "size: " << std::distance(v3.begin(), v3_end) << std::endl;
52
53 return 0;
54 }