]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
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 <algorithm> | |
12 | #include <iostream> | |
13 | #include <numeric> | |
14 | #include <vector> | |
15 | ||
16 | #include "perf.hpp" | |
17 | ||
18 | int rand_int() | |
19 | { | |
20 | return static_cast<int>((rand() / double(RAND_MAX)) * 25.0); | |
21 | } | |
22 | ||
23 | int main(int argc, char *argv[]) | |
24 | { | |
25 | perf_parse_args(argc, argv); | |
26 | std::cout << "size: " << PERF_N << std::endl; | |
27 | ||
28 | // create vector of random numbers on the host | |
29 | std::vector<int> host_vector(PERF_N); | |
30 | std::generate(host_vector.begin(), host_vector.end(), rand_int); | |
31 | ||
32 | std::vector<int> host_vector2(PERF_N); | |
33 | std::copy(host_vector.rbegin(), host_vector.rend(), host_vector2.begin()); | |
34 | ||
35 | perf_timer t; | |
36 | for(size_t trial = 0; trial < PERF_TRIALS; trial++){ | |
37 | t.start(); | |
38 | std::is_permutation(host_vector.begin(), host_vector.end(), | |
39 | host_vector2.begin()); | |
40 | t.stop(); | |
41 | } | |
42 | std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl; | |
43 | ||
44 | return 0; | |
45 | } |