MCPcopy Create free account
hub / github.com/boostorg/asio / main

Function main

example/cpp14/parallel_group/parallel_sort.cpp:106–134  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

104}
105
106int main()
107{
108 boost::asio::thread_pool pool(4);
109
110 std::vector<int> values(100'000'000);
111
112 std::random_device random_device;
113 std::mt19937 rng(random_device());
114 std::uniform_int_distribution<int> dist(1, 1'000'000);
115 std::generate(values.begin(), values.end(), [&]{ return dist(rng); });
116
117 std::cout << "starting sort\n";
118
119 auto begin = std::chrono::high_resolution_clock::now();
120
121 parallel_sort(
122 pool.get_executor(),
123 values.begin(),
124 values.end(),
125 boost::asio::use_future
126 ).get();
127
128 auto end = std::chrono::high_resolution_clock::now();
129
130 auto duration = end - begin;
131 std::cout << "sort took "
132 << std::chrono::duration_cast<std::chrono::microseconds>(duration).count()
133 << " microseconds\n";
134}

Callers

nothing calls this directly

Calls 7

parallel_sortFunction · 0.85
nowFunction · 0.50
beginMethod · 0.45
endMethod · 0.45
getMethod · 0.45
get_executorMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected