MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / verify

Function verify

examples/sort/bench_byte_swap.cpp:107–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

105// Correctness check: swap two distinct buffers, check that contents exchanged.
106template <typename Fn>
107void verify(const char * name, Fn fn, size_t width) {
108 std::vector<unsigned char> a(width), b(width), a0(width), b0(width);
109 std::mt19937 rng(0xBADBEEFu);
110 for (size_t i = 0; i < width; i++) { a[i] = a0[i] = (unsigned char)(rng() & 0xFF); b[i] = b0[i] = (unsigned char)(rng() & 0xFF); }
111 fn(a.data(), b.data(), width);
112 if (memcmp(a.data(), b0.data(), width) != 0 || memcmp(b.data(), a0.data(), width) != 0) {
113 std::fprintf(stderr, "FAIL: '%s' produced wrong swap at width=%zu\n", name, width);
114 std::abort();
115 }
116}
117
118template <typename Fn>
119double time_op(Fn fn, size_t width, size_t pairs, int iters)

Callers 9

beforeDimMethod · 0.85
run_widthFunction · 0.85
bench_oneFunction · 0.85
addExternPropertyFunction · 0.85
addExternPropertyForTypeFunction · 0.85
addExternFunction · 0.85
makeExternFunction · 0.85
addExternExFunction · 0.85
addExternTempRefFunction · 0.85

Calls 3

fnFunction · 0.85
fprintfFunction · 0.85
dataMethod · 0.45

Tested by

no test coverage detected