-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcpubound.cpp
More file actions
32 lines (27 loc) · 808 Bytes
/
cpubound.cpp
File metadata and controls
32 lines (27 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* This is free and unencumbered software released into the public domain.
* Refer to LICENSE.txt in this directory. */
/* Compute-bound workload that sorts random numbers. */
#include <algorithm>
#include <array>
#include <iostream>
#include <random>
int
main()
{
std::array<int, 1000000> numbers;
std::random_device rng_device;
std::default_random_engine rng(rng_device());
std::uniform_int_distribution<int> uint_dist;
for (;;)
{
std::cout << "Initialising random numbers..." << std::endl;
for (auto &number : numbers)
{
number = uint_dist(rng);
}
std::cout << "Starting sort..." << std::endl;
std::sort(numbers.begin(), numbers.end());
std::cout << "Sorted." << std::endl;
}
return EXIT_SUCCESS;
}