Skip to content

Example fails to run (std::system_error) #67

Closed

Description

Tried to run first example (master @ d750144) and got following result:

terminate called after throwing an instance of 'std::system_error'
  what():  Unknown error -1

As I checked any of following lines (even when run alone) cause that problem:

benchmark::Initialize(&argc, (const char **) argv);
benchmark::RunSpecifiedBenchmarks();

Full file for reference:

#include <string>
#include "benchmark/benchmark.h"

static void BM_StringCreation(benchmark::State& state) {
  while (state.KeepRunning())
    std::string empty_string;
}
// Register the function as a benchmark
BENCHMARK(BM_StringCreation);

// Define another benchmark
static void BM_StringCopy(benchmark::State& state) {
  std::string x = "hello";
  while (state.KeepRunning())
    std::string copy(x);
}
BENCHMARK(BM_StringCopy);

// Augment the main() program to invoke benchmarks if specified
// via the --benchmarks command line flag.  E.g.,
//       my_unittest --benchmark_filter=all
//       my_unittest --benchmark_filter=BM_StringCreation
//       my_unittest --benchmark_filter=String
//       my_unittest --benchmark_filter='Copy|Creation'
int main(int argc, char** argv) {
  benchmark::Initialize(&argc, (const char **) argv);
  benchmark::RunSpecifiedBenchmarks();
  return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions