llvm-project/libcxx/benchmarks/exception_ptr.bench.cpp
itrofimow 51e91b64d0
[libc++abi] Implement __cxa_init_primary_exception and use it to optimize std::make_exception_ptr (#65534)
This patch implements __cxa_init_primary_exception, an extension to the 
Itanium C++ ABI. This extension is already present in both libsupc++ and 
libcxxrt. This patch also starts making use of this function in 
std::make_exception_ptr: instead of going through a full throw/catch 
cycle, we are now able to initialize an exception directly, thus making 
std::make_exception_ptr around 30x faster.
2024-01-22 10:12:41 -05:00

20 lines
641 B
C++

//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
#include <benchmark/benchmark.h>
#include <exception>
void bm_make_exception_ptr(benchmark::State& state) {
for (auto _ : state) {
benchmark::DoNotOptimize(std::make_exception_ptr(42));
}
}
BENCHMARK(bm_make_exception_ptr)->ThreadRange(1, 8);
BENCHMARK_MAIN();