Sorted Array

std::vector<int> arr(100'000);
# then fill with random value in [0, 256]

for (auto i = 0u; i < 100'000; ++i) {
  if (arr[i] >= 128)
    sum += arr[i];
}
std::vector<int> arr(100'000);
# then fill with random value in [0, 256]

# do not benchmark this sort function
std::sort(arr.begin(), arr.end())

for (auto i = 0u; i < 100'000; ++i) {
  if (arr[i] >= 128)
    sum += arr[i];
}

* The benchmark is run under Apple Macbook Air M2.

* For the full benchmark code, please refer here.