MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / test_case

Function test_case

test/benchmark/benchmark_memcpy.cpp:56–93  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54double totalTimeSecs = 0.0;
55
56void 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
95void print_results()
96{

Callers 1

run_oneFunction · 0.70

Calls 4

ticks_per_secFunction · 0.85
tickFunction · 0.70
test_memcpyFunction · 0.70
push_backMethod · 0.65

Tested by

no test coverage detected