diff options
author | yazevnul <yazevnul@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
---|---|---|
committer | Daniil Cherednik <dcherednik@yandex-team.ru> | 2022-02-10 16:46:46 +0300 |
commit | 8cbc307de0221f84c80c42dcbe07d40727537e2c (patch) | |
tree | 625d5a673015d1df891e051033e9fcde5c7be4e5 /library/cpp/testing/benchmark/examples/main.cpp | |
parent | 30d1ef3941e0dc835be7609de5ebee66958f215a (diff) | |
download | ydb-8cbc307de0221f84c80c42dcbe07d40727537e2c.tar.gz |
Restoring authorship annotation for <yazevnul@yandex-team.ru>. Commit 1 of 2.
Diffstat (limited to 'library/cpp/testing/benchmark/examples/main.cpp')
-rw-r--r-- | library/cpp/testing/benchmark/examples/main.cpp | 82 |
1 files changed, 41 insertions, 41 deletions
diff --git a/library/cpp/testing/benchmark/examples/main.cpp b/library/cpp/testing/benchmark/examples/main.cpp index ddd8b05ffc..745e636d4c 100644 --- a/library/cpp/testing/benchmark/examples/main.cpp +++ b/library/cpp/testing/benchmark/examples/main.cpp @@ -120,9 +120,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -131,9 +131,9 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef1, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); + NBench::Escape(&x); Y_DO_NOT_OPTIMIZE_AWAY(FS2(x)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -143,10 +143,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufVal2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS1_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -156,10 +156,10 @@ Y_CPU_BENCHMARK(FunctionCallCost_StringBufRef2, iface) { for (auto i : xrange<size_t>(0, iface.Iterations())) { (void)i; - NBench::Escape(&x); - NBench::Escape(&y); + NBench::Escape(&x); + NBench::Escape(&y); Y_DO_NOT_OPTIMIZE_AWAY(FS2_2(x, y)); - NBench::Clobber(); + NBench::Clobber(); } } @@ -181,35 +181,35 @@ Y_CPU_BENCHMARK(FunctionCallCost_TwoArg, iface) { Y_DO_NOT_OPTIMIZE_AWAY(FFF(i, i)); } } - -/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: - * @code - * │ push %rbp - * │ mov %rsp,%rbp - * │ push %rbx - * │ push %rax - * │ mov (%rdi),%rbx - * │ test %rbx,%rbx - * │ ↓ je 25 - * │ xor %edi,%edi - * │ xor %esi,%esi + +/* An example of incorrect benchmark. As of r2581591 Clang 3.7 produced following assembly: + * @code + * │ push %rbp + * │ mov %rsp,%rbp + * │ push %rbx + * │ push %rax + * │ mov (%rdi),%rbx + * │ test %rbx,%rbx + * │ ↓ je 25 + * │ xor %edi,%edi + * │ xor %esi,%esi * │ → callq FS1(TBasicStringBuf<char, std::char_traits<char - * │ nop - * 100.00 │20:┌─→dec %rbx - * │ └──jne 20 - * │25: add $0x8,%rsp - * │ pop %rbx - * │ pop %rbp - * │ ← retq - * @endcode - * - * So, this benchmark is measuring empty loop! - */ -Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { - TStringBuf x; - - for (auto i : xrange<size_t>(0, iface.Iterations())) { - (void)i; - Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); - } -} + * │ nop + * 100.00 │20:┌─→dec %rbx + * │ └──jne 20 + * │25: add $0x8,%rsp + * │ pop %rbx + * │ pop %rbp + * │ ← retq + * @endcode + * + * So, this benchmark is measuring empty loop! + */ +Y_CPU_BENCHMARK(Incorrect_FunctionCallCost_StringBufVal1, iface) { + TStringBuf x; + + for (auto i : xrange<size_t>(0, iface.Iterations())) { + (void)i; + Y_DO_NOT_OPTIMIZE_AWAY(FS1(x)); + } +} |