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
rand_int()17 int rand_int()
18 {
19 return static_cast<int>((rand() / double(RAND_MAX)) * 25.0);
20 }
21
main(int argc,char * argv[])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(PERF_N);
29 std::generate(v1.begin(), v1.end(), rand_int);
30
31 std::vector<int> v2(v1);
32
33 std::sort(v1.begin(), v1.end());
34 std::sort(v2.begin(), v2.end());
35
36 perf_timer t;
37 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
38 t.start();
39 std::includes(
40 v1.begin(), v1.end(),
41 v2.begin(), v2.end()
42 );
43 t.stop();
44 }
45 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
46
47 return 0;
48 }
49