-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.cpp
58 lines (47 loc) · 1.62 KB
/
main.cpp
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include "CountingSort.hpp"
#include "InsertionSort.hpp"
#include "MergeSort.hpp"
#include "QuickSort.hpp"
#include "vector_helpers.hpp"
#include "timeit.hpp"
#include <iostream>
#include <vector>
#include <cassert>
int main() {
auto nums = generate_random_vector<int>(10'000'000, -1'000, 1'000);
auto sorted(nums);
ti::ti cpp_sort_timer("std::sort");
std::sort(sorted.begin(), sorted.end());
cpp_sort_timer.finish();
auto nums_cpy(nums);
ti::ti counting_sort_timer("Counting Sort");
counting_sort<int>(std::begin(nums_cpy), std::end(nums_cpy));
counting_sort_timer.finish();
assert(nums_cpy == sorted);
nums_cpy = nums;
ti::ti parallel_counting_sort_timer("Parallel Counting Sort");
parallel_counting_sort<int>(std::begin(nums_cpy), std::end(nums_cpy));
parallel_counting_sort_timer.finish();
assert(nums_cpy == sorted);
nums_cpy = nums;
ti::ti insertion_sort_timer("Insertion Sort");
insertion_sort<int>(std::begin(nums_cpy), std::end(nums_cpy));
insertion_sort_timer.finish();
assert(nums_cpy == sorted);
nums_cpy = nums;
ti::ti merge_sort_timer("Merge Sort");
merge_sort<int>(nums_cpy);
merge_sort_timer.finish();
assert(nums_cpy == sorted);
nums_cpy = nums;
ti::ti parallel_merge_sort_timer("Parallel Merge Sort");
parallel_merge_sort<int>(nums_cpy);
parallel_merge_sort_timer.finish();
assert(nums_cpy == sorted);
nums_cpy = nums;
ti::ti quick_sort_timer("Quick Sort");
quick_sort<int>(std::begin(nums_cpy), std::end(nums_cpy));
quick_sort_timer.finish();
assert(nums_cpy == sorted);
return 0;
}