mirror of
https://github.com/google/benchmark.git
synced 2025-04-12 20:41:14 +08:00
fix all
This commit is contained in:
commit
d0b4cb6b16
@ -4,7 +4,6 @@ project (benchmark)
|
||||
option(BENCHMARK_ENABLE_SHARED "Enable building a shared library." OFF)
|
||||
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." ON)
|
||||
set(BENCHMARK_LOGGING_LEVEL "0" CACHE STRING "The logging level to use.")
|
||||
|
||||
# Make sure we can import out CMake functions
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
|
||||
@ -14,6 +13,9 @@ endif()
|
||||
|
||||
# Enable the latest C++ standard possible
|
||||
include(CheckCXXCompilerFlag)
|
||||
include(AddCXXCompilerFlag)
|
||||
include(CXXFeatureCheck)
|
||||
|
||||
check_cxx_compiler_flag(-std=c++11 HAVE_FLAG_CXX_11)
|
||||
check_cxx_compiler_flag(-std=c++0x HAVE_FLAG_CXX_0X)
|
||||
if (HAVE_FLAG_CXX_11)
|
||||
@ -22,10 +24,8 @@ elseif (HAVE_FLAG_CXX_0X)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
|
||||
endif()
|
||||
|
||||
# Turn compiler warnings up to 11
|
||||
include(AddCXXCompilerFlag)
|
||||
include(CXXFeatureCheck)
|
||||
|
||||
# Turn compiler warnings up to 11
|
||||
add_cxx_compiler_flag(-Wall)
|
||||
add_cxx_compiler_flag(-Wextra)
|
||||
add_cxx_compiler_flag(-Wshadow)
|
||||
@ -42,11 +42,14 @@ endif()
|
||||
# Release flags
|
||||
add_cxx_compiler_flag(-fno-strict-aliasing RELEASE)
|
||||
|
||||
|
||||
|
||||
# C++ feature checks
|
||||
cxx_feature_check(STD_REGEX)
|
||||
cxx_feature_check(GNU_POSIX_REGEX)
|
||||
cxx_feature_check(POSIX_REGEX)
|
||||
|
||||
|
||||
# Set up directories
|
||||
include_directories(${PROJECT_SOURCE_DIR}/include)
|
||||
|
||||
|
@ -68,7 +68,7 @@ DEFINE_string(benchmarks, "all",
|
||||
"If this flag is the string \"all\", all benchmarks linked "
|
||||
"into the process are run.");
|
||||
|
||||
DEFINE_int32(benchmark_min_iters, 100,
|
||||
DEFINE_int32(benchmark_min_iters, 1,
|
||||
"Minimum number of iterations per benchmark");
|
||||
|
||||
DEFINE_int32(benchmark_max_iters, 1000000000,
|
||||
@ -646,9 +646,13 @@ void RunBenchmark(const benchmark::Benchmark::Instance& b,
|
||||
|
||||
// See how much iterations should be increased by
|
||||
// Note: Avoid division by zero with max(seconds, 1ns).
|
||||
double multiplier = 1.4 * FLAGS_benchmark_min_time /
|
||||
std::max(seconds, 1e-9);
|
||||
multiplier = std::min(10.0, multiplier); // At most 10 times expansion
|
||||
double multiplier = FLAGS_benchmark_min_time * 1.4 / std::max(seconds, 1e-9);
|
||||
// If our last run was at least 10% of FLAGS_benchmark_min_time then we
|
||||
// use the multiplier directly. Otherwise we use at most 10 times
|
||||
// expansion.
|
||||
bool is_significant = (seconds / FLAGS_benchmark_min_time) > 0.1;
|
||||
multiplier = is_significant ? multiplier : std::min(10.0, multiplier);
|
||||
// TODO(ericwf) I don't think this branch is reachable.
|
||||
if (multiplier <= 1.0) multiplier = 2.0;
|
||||
double next_iters = std::max(multiplier * iters, iters + 1.0);
|
||||
if (next_iters > FLAGS_benchmark_max_iters) {
|
||||
|
@ -155,7 +155,7 @@ static void BM_LongTest(benchmark::State& state) {
|
||||
while (state.KeepRunning())
|
||||
for (int i = 0; i < state.range_x(); ++i)
|
||||
tracker += i;
|
||||
assert(tracker != 0.0);
|
||||
assert(tracker > 1.0);
|
||||
}
|
||||
BENCHMARK(BM_LongTest)->Range(1<<16,1<<28);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user