Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // main.cpp
- // Benchmark
- //
- // Created by Guilherme Avila on 05/02/17.
- // Copyright © 2017 guilhermebav. All rights reserved.
- //
- #include <hayai.hpp>
- #include <iostream>
- #include <vector>
- #include <algorithm>
- #include <limits>
- #include "sorts.hpp"
- using namespace std;
- //const unsigned maxv = numeric_limits<unsigned int>::max();
- const unsigned maxv = 500000;
- const int test = 20;
- const int runs = 1000;
- const int size = 200000;
- vector<vector<unsigned>> d(runs, vector<unsigned>(size));
- vector<unsigned> v(size);
- int i=0;
- //int main(int argc, const char * argv[]) {
- // srand((unsigned)time(NULL));
- // vector<unsigned> z;
- // for (int i=0; i < test; i++){
- // int b = (2*rand()) % maxv + 1;
- // z.push_back(b);
- // }
- // for (int i=0; i < test; i++){
- // cout << z[i] << " ";
- // }
- // cout << endl;
- // c_radix_sort(z.begin(), z.end());
- // cout << endl;
- // for (int i=0; i < test; i++){
- // cout << z[i] << " ";
- // }
- // cout << endl;
- // return 0;
- //}
- int main(int argc, const char * argv[]) {
- srand((unsigned)time(NULL));
- for(int i=0;i<runs;i++) {
- for(int j=0;j<size;j++){
- int b = (2*rand()) % maxv + 1;
- d[i][j] = b;
- }
- }
- i=0;
- hayai::ConsoleOutputter consoleOutputter;
- hayai::Benchmarker::AddOutputter(consoleOutputter);
- hayai::Benchmarker::RunAllTests();
- return 0;
- }
- bool myfunction (int i,int j) { return (i<j); }
- class Sorts : public ::hayai::Fixture {
- public:
- virtual void SetUp() {
- v.assign(d[i].begin(),d[i].end());
- // sort(v.begin(), v.end());
- // reverse(v.begin(),v.end());
- }
- virtual void TearDown() {
- i++;
- if(i==runs) i=0;
- }
- };
- //BENCHMARK_F(Sorts, merge_sort, runs, 1) {
- // merge_sort(v.begin(), v.end());
- //}
- //
- //BENCHMARK_F(Sorts, c_merge_sort, runs, 1) {
- // c_merge_sort(v.begin(), v.end());
- //}
- //
- //BENCHMARK_F(Sorts, quick_sort, runs, 1) {
- // quick_sort(v.begin(), v.end());
- //}
- //
- //BENCHMARK_F(Sorts, tim_sort, runs, 1) {
- // tim_sort(v.begin(), v.end());
- //}
- BENCHMARK_F(Sorts, radix_sort, runs, 1) {
- radix_sort(v.begin(), v.end());
- }
- //BENCHMARK_F(Sorts, stl_sort, runs, 1) {
- // sort(v.begin(), v.end());
- //}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement