GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — sort/test-executor.cpp at master · allmycode/sort Expand file tree/ Copy pathtest-executor.cppMore file actions 76 lines (61 loc) · 1.54 KB / Copy pathtest-executor.cppFile metadata and controls76 lines (61 loc) · 1.54 KB 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 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 #include <iostream> #include <iomanip> #include <fstream> #include <string> #include <cstdlib> #include <cmath> #include "util.hpp" #include "sort.h" #include "../libcpp/measurer.h" const int TRIES = 1; const int MIN_POWER = 5; const int MAX_POWER = 8; int* dt[MAX_POWER - MIN_POWER + 1][TRIES]; void prepareTestData() { srand(4222); int size = pow(10, MIN_POWER); for (int i = MIN_POWER; i <= MAX_POWER; i++) { for (int j = 0; j < TRIES; j++) { int*a = dt[i][j] = new int[size]; for (int k = 0; k < size; k++) a[k] = rand(); } size *= 10; } } void doTests(std::string sortname) { int size = pow(10, MIN_POWER); std::cout << "Start tests " << sortname << " ..." << std::endl; // do tests for (int i = MIN_POWER; i <= MAX_POWER; i++) { for (int j = 0; j < TRIES; j++) { measurer m; if ("quick" == sortname) quicksort(dt[i][j], size); else if ("merge" == sortname) mergesort(dt[i][j], size); else heapsort(dt[i][j], size); std::cout << "Test " << j << " on " << size << " took " << std::setprecision(4) << m.seconds() << " seconds" << std::endl; } size *= 10; } std::cout << "Finished tests ..." << std::endl; } void cleanUp() { for (int i = MIN_POWER; i <= MAX_POWER; i++) { for (int j = 0; j < TRIES; j++) { delete[] dt[i][j]; } } } int main(int argc, const char* argv[]) { std::string sortname = "quick"; if (argc > 1) sortname = argv[1]; prepareTestData(); doTests(sortname); cleanUp(); return 0; } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |