2 * Copyright 2017 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
21 #include <glog/logging.h>
23 #include <folly/Benchmark.h>
24 #include <folly/experimental/exception_tracer/ExceptionTracer.h>
25 #include <folly/portability/GFlags.h>
27 void recurse(int level) {
29 throw std::runtime_error("");
32 folly::doNotOptimizeAway(0); // prevent tail recursion
35 void loop(int iters) {
36 for (int i = 0; i < iters * 100; ++i) {
39 } catch (const std::exception& e) {
40 folly::exception_tracer::getCurrentExceptions();
45 BENCHMARK(ExceptionTracer, iters) {
46 std::vector<std::thread> threads;
47 constexpr size_t kNumThreads = 10;
48 threads.resize(kNumThreads);
49 for (auto& t : threads) {
50 t = std::thread([iters]() { loop(iters); });
52 for (auto& t : threads) {
57 int main(int argc, char* argv[]) {
58 gflags::ParseCommandLineFlags(&argc, &argv, true);
59 google::InitGoogleLogging(argv[0]);
60 folly::runBenchmarks();