| 54 | double totalTimeSecs = 0.0; |
| 55 | |
| 56 | void test_case(int copySize) |
| 57 | { |
| 58 | const int minimumCopyBytes = 1024*1024*64; |
| 59 | |
| 60 | int numTimes = (minimumCopyBytes + copySize-1) / copySize; |
| 61 | if (numTimes < 8) numTimes = 8; |
| 62 | |
| 63 | tick_t bestResult = 1e9; |
| 64 | |
| 65 | #ifndef NUM_TRIALS |
| 66 | #define NUM_TRIALS 5 |
| 67 | #endif |
| 68 | |
| 69 | for(int i = 0; i < NUM_TRIALS; ++i) |
| 70 | { |
| 71 | double t0 = tick(); |
| 72 | test_memcpy(numTimes, copySize); |
| 73 | double t1 = tick(); |
| 74 | if (t1 - t0 < bestResult) bestResult = t1 - t0; |
| 75 | totalTimeSecs += (double)(t1 - t0) / ticks_per_sec(); |
| 76 | } |
| 77 | unsigned long long totalBytesTransferred = numTimes * copySize; |
| 78 | |
| 79 | copySizes.push_back(copySize); |
| 80 | |
| 81 | tick_t ticksElapsed = bestResult; |
| 82 | if (ticksElapsed > 0) |
| 83 | { |
| 84 | double seconds = (double)ticksElapsed / ticks_per_sec(); |
| 85 | double bytesPerSecond = totalBytesTransferred / seconds; |
| 86 | double mbytesPerSecond = bytesPerSecond / (1024.0*1024.0); |
| 87 | results.push_back(mbytesPerSecond); |
| 88 | } |
| 89 | else |
| 90 | { |
| 91 | results.push_back(0.0); |
| 92 | } |
| 93 | } |
| 94 | |
| 95 | void print_results() |
| 96 | { |
no test coverage detected