3 #include <lemon/time_measure.h>
4 #include <lemon/smart_graph.h>
5 #include <lemon/graph_utils.h>
6 #include <lemon/maps.h>
7 #include <lemon/error.h>
9 #include <lemon/radix_sort.h>
16 using namespace lemon;
18 void testRadixSort() {
21 for (int i = 0; i < n; ++i) {
22 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
24 radixSort(data.begin(), data.end());
28 void testCounterSort() {
31 for (int i = 0; i < n; ++i) {
32 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
34 counterSort(data.begin(), data.end());
40 for (int i = 0; i < n; ++i) {
41 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
43 sort(data.begin(), data.end());
46 void testStableSort() {
49 for (int i = 0; i < n; ++i) {
50 data[i] = (int)(1000 * (rand() / (RAND_MAX + 1.0))) - 500;
52 stable_sort(data.begin(), data.end());
60 cout << "Radix sort: " << runningTimeTest(testRadixSort, 60) << endl;
61 cout << "Counter sort: " << runningTimeTest(testCounterSort, 60) << endl;
62 cout << "Standard sort: " << runningTimeTest(testSort, 60) << endl;
63 cout << "Stable sort: " << runningTimeTest(testStableSort, 60) << endl;