mirror of
https://gitee.com/openharmony/third_party_benchmark
synced 2024-11-23 07:20:12 +00:00
Remove sleep.h dependency for tests
This commit is contained in:
parent
f352c30f1c
commit
fb733897c5
@ -1,9 +1,5 @@
|
||||
# Enable the tests
|
||||
|
||||
# Allow the test files to find headers in src/ since we rely on
|
||||
# SleepForMilliseconds(int milliseconds) in options_test.cc
|
||||
include_directories(${PROJECT_SOURCE_DIR}/src)
|
||||
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
set(CXX03_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
@ -1,5 +1,7 @@
|
||||
#include "benchmark/benchmark_api.h"
|
||||
#include "sleep.h"
|
||||
|
||||
#include <chrono>
|
||||
#include <thread>
|
||||
|
||||
void BM_basic(benchmark::State& state) {
|
||||
while (state.KeepRunning()) {
|
||||
@ -7,8 +9,14 @@ void BM_basic(benchmark::State& state) {
|
||||
}
|
||||
|
||||
void BM_basic_slow(benchmark::State& state) {
|
||||
|
||||
int milliseconds = state.range_x();
|
||||
std::chrono::duration<double, std::milli> sleep_duration {
|
||||
static_cast<double>(milliseconds)
|
||||
};
|
||||
|
||||
while (state.KeepRunning()) {
|
||||
benchmark::SleepForMilliseconds(state.range_x());
|
||||
std::this_thread::sleep_for(sleep_duration);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user