MCPcopy Create free account
hub / github.com/antmachineintelligence/mtgbmcode / main

Function main

compute/perf/perf_stl_find.cpp:25–58  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

23}
24
25int main(int argc, char *argv[])
26{
27 perf_parse_args(argc, argv);
28 std::cout << "size: " << PERF_N << std::endl;
29
30 // create vector of random numbers on the host
31 std::vector<int> host_vector(PERF_N);
32 std::generate(host_vector.begin(), host_vector.end(), rand_int);
33
34 // trying to find element that isn't in vector (worst-case scenario)
35 int wanted = rand_int_max + 1;
36
37 // result
38 std::vector<int>::iterator host_result_it;
39
40 perf_timer t;
41 for(size_t trial = 0; trial < PERF_TRIALS; trial++){
42 t.start();
43 host_result_it = std::find(host_vector.begin(), host_vector.end(), wanted);
44 t.stop();
45 }
46 std::cout << "time: " << t.min_time() / 1e6 << " ms" << std::endl;
47
48 // verify
49 if(host_result_it != host_vector.end()){
50 std::cout << "ERROR: "
51 << "host_result_iterator != "
52 << "host_vector.end()"
53 << std::endl;
54 return -1;
55 }
56
57 return 0;
58}

Callers

nothing calls this directly

Calls 8

perf_parse_argsFunction · 0.85
findFunction · 0.85
startMethod · 0.80
stopMethod · 0.80
min_timeMethod · 0.80
generateFunction · 0.50
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected