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 #include <string> 10 #include <system_error> 11 12 #include "benchmark/benchmark.h" 13 BM_SystemErrorWithMessage(benchmark::State & state)14static void BM_SystemErrorWithMessage(benchmark::State& state) { 15 for (auto _ : state) { 16 std::error_code ec{}; 17 benchmark::DoNotOptimize(std::system_error{ec, ""}); 18 } 19 } 20 BENCHMARK(BM_SystemErrorWithMessage); 21 BM_SystemErrorWithoutMessage(benchmark::State & state)22static void BM_SystemErrorWithoutMessage(benchmark::State& state) { 23 for (auto _ : state) { 24 std::error_code ec{}; 25 benchmark::DoNotOptimize(std::system_error{ec}); 26 } 27 } 28 BENCHMARK(BM_SystemErrorWithoutMessage); 29 30 BENCHMARK_MAIN(); 31