| 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
| 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. |
| 4 | // See https://llvm.org/LICENSE.txt for license information. |
| 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
| 9 | // UNSUPPORTED: c++03 |
| 10 | |
| 11 | #include <string> |
| 12 | #include <system_error> |
| 13 | |
| 14 | #include "benchmark/benchmark.h" |
| 15 | |
| 16 | static void BM_SystemErrorWithMessage(benchmark::State& state) { |
| 17 | for (auto _ : state) { |
| 18 | std::error_code ec{}; |
| 19 | benchmark::DoNotOptimize(std::system_error{ec, "" }); |
| 20 | } |
| 21 | } |
| 22 | BENCHMARK(BM_SystemErrorWithMessage); |
| 23 | |
| 24 | static void BM_SystemErrorWithoutMessage(benchmark::State& state) { |
| 25 | for (auto _ : state) { |
| 26 | std::error_code ec{}; |
| 27 | benchmark::DoNotOptimize(std::system_error{ec}); |
| 28 | } |
| 29 | } |
| 30 | BENCHMARK(BM_SystemErrorWithoutMessage); |
| 31 | |
| 32 | BENCHMARK_MAIN(); |
| 33 | |