Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
catch_benchmark.cpp
Go to the documentation of this file.
1/*
2 * Created by Phil on 04/07/2017.
3 * Copyright 2017 Two Blue Cubes Ltd. All rights reserved.
4 *
5 * Distributed under the Boost Software License, Version 1.0. (See accompanying
6 * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
7 */
8
9#include "catch_benchmark.h"
10#include "catch_capture.hpp"
12#include "catch_context.h"
13
14namespace Catch {
15
16 auto BenchmarkLooper::getResolution() -> uint64_t {
17 return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple();
18 }
19
24 auto elapsed = m_timer.getElapsedNanoseconds();
25
26 // Exponentially increasing iterations until we're confident in our timer resolution
27 if( elapsed < m_resolution ) {
28 m_iterationsToRun *= 10;
29 return true;
30 }
31
32 getResultCapture().benchmarkEnded( { { m_name }, m_count, elapsed } );
33 return false;
34 }
35
36} // end namespace Catch
auto needsMoreIterations() -> bool
IContext & getCurrentContext()
auto getEstimatedClockResolution() -> uint64_t
IResultCapture & getResultCapture()
unsigned __int64 uint64_t
Definition stdint.h:136
virtual IConfigPtr const & getConfig() const =0
virtual void benchmarkStarting(BenchmarkInfo const &info)=0
virtual void benchmarkEnded(BenchmarkStats const &stats)=0