am 6542ac03: Merge "Add a memmove(3) benchmark."
* commit '6542ac0380581e0cd0ad47e2763b732d93e9d6bd': Add a memmove(3) benchmark.
This commit is contained in:
commit
c079dfe415
|
@ -62,6 +62,22 @@ static void BM_memcpy(int iters, int nbytes) {
|
||||||
}
|
}
|
||||||
BENCHMARK(BM_memcpy)->AT_COMMON_SIZES;
|
BENCHMARK(BM_memcpy)->AT_COMMON_SIZES;
|
||||||
|
|
||||||
|
static void BM_memmove(int iters, int nbytes) {
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
char* buf = new char[nbytes + 64];
|
||||||
|
memset(buf, 'x', nbytes + 64);
|
||||||
|
StartBenchmarkTiming();
|
||||||
|
|
||||||
|
for (int i = 0; i < iters; i++) {
|
||||||
|
memmove(buf, buf + 1, nbytes); // Worst-case overlap.
|
||||||
|
}
|
||||||
|
|
||||||
|
StopBenchmarkTiming();
|
||||||
|
SetBenchmarkBytesProcessed(int64_t(iters) * int64_t(nbytes));
|
||||||
|
delete[] buf;
|
||||||
|
}
|
||||||
|
BENCHMARK(BM_memmove)->AT_COMMON_SIZES;
|
||||||
|
|
||||||
static void BM_memset(int iters, int nbytes) {
|
static void BM_memset(int iters, int nbytes) {
|
||||||
StopBenchmarkTiming();
|
StopBenchmarkTiming();
|
||||||
char* dst = new char[nbytes];
|
char* dst = new char[nbytes];
|
||||||
|
|
Loading…
Reference in New Issue