-
-
Save anonymous/9442b3c5ad9a24283c36 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NONIUS_BENCHMARK("std::sort unsorted", [](nonius::chronometer meter) | |
{ | |
std::mt19937_64 el(time(nullptr)); | |
std::vector<int> v; | |
for (int i = 0; i < size; ++i) | |
v.push_back(i); | |
std::shuffle(v.begin(), v.end(), el); | |
meter.measure([&]() | |
{ | |
for (int i = 0; i < size; i += chunk_size) | |
{ | |
std::sort(v.begin() + i, v.begin() + i + chunk_size); | |
} | |
}); | |
}) | |
NONIUS_BENCHMARK("introsort unsorted", [](nonius::chronometer meter) | |
{ | |
std::mt19937_64 el(time(nullptr)); | |
std::vector<int> v; | |
for (int i = 0; i < size; ++i) | |
v.push_back(i); | |
std::shuffle(v.begin(), v.end(), el); | |
meter.measure([&]() | |
{ | |
for (int i = 0; i < size; i += chunk_size) | |
{ | |
introsort(v.begin() + i, v.begin() + i + chunk_size); | |
} | |
}); | |
}) | |
NONIUS_BENCHMARK("std::sort sorted", [](nonius::chronometer meter) | |
{ | |
std::mt19937_64 el(time(nullptr)); | |
std::vector<int> v; | |
for (int i = 0; i < size; ++i) | |
v.push_back(i); | |
meter.measure([&]() | |
{ | |
for (int i = 0; i < size; i += chunk_size) | |
{ | |
std::sort(v.begin() + i, v.begin() + i + chunk_size); | |
} | |
}); | |
}) | |
NONIUS_BENCHMARK("introsort sorted", [](nonius::chronometer meter) | |
{ | |
std::mt19937_64 el(time(nullptr)); | |
std::vector<int> v; | |
for (int i = 0; i < size; ++i) | |
v.push_back(i); | |
meter.measure([&]() | |
{ | |
for (int i = 0; i < size; i += chunk_size) | |
{ | |
introsort(v.begin() + i, v.begin() + i + chunk_size); | |
} | |
}); | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment