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

source code of libcxx/benchmarks/system_error.bench.cpp