8#ifndef INCLUDED_BSLS_STOPWATCH
9#define INCLUDED_BSLS_STOPWATCH
123#include <bsls_keyword.h>
158 TimeUtil::OpaqueNativeTime d_startWallTime;
174 bool d_collectCpuTimesFlag;
178 static const double s_nanosecondsPerSecond;
199 TimeUtil::OpaqueNativeTime *wallTime)
const;
203 Types::Int64 elapsedWallTime(TimeUtil::OpaqueNativeTime rawWallTime)
const;
219#ifdef BSLS_COMPILERFEATURES_SUPPORT_DEFAULTED_FUNCTIONS
253 void start(
bool collectCpuTimes =
false);
274 double *wallTime)
const;
305void Stopwatch::accumulatedTimesRaw(
Types::Int64 *systemTime,
307 TimeUtil::OpaqueNativeTime *wallTime)
const
315 TimeUtil::OpaqueNativeTime rawWallTime)
const
324: d_startSystemTime(0)
327, d_accumulatedSystemTime(0)
328, d_accumulatedUserTime(0)
329, d_accumulatedWallTime(0)
331, d_collectCpuTimesFlag(false)
334 memset(&d_startWallTime, 0,
sizeof(d_startWallTime));
342 d_accumulatedSystemTime = 0;
343 d_accumulatedUserTime = 0;
344 d_accumulatedWallTime = 0;
351 d_collectCpuTimesFlag = collectCpuTimes;
352 if (d_collectCpuTimesFlag) {
353 accumulatedTimesRaw(&d_startSystemTime,
368 if (d_collectCpuTimesFlag) {
372 TimeUtil::OpaqueNativeTime now;
374 d_accumulatedWallTime += elapsedWallTime(now);
384 if (!d_collectCpuTimesFlag) {
389 return (
double)(d_accumulatedSystemTime
391 / s_nanosecondsPerSecond;
394 return (
double)d_accumulatedSystemTime / s_nanosecondsPerSecond;
400 if (!d_collectCpuTimesFlag) {
405 return (
double)(d_accumulatedUserTime
407 / s_nanosecondsPerSecond;
410 return (
double)d_accumulatedUserTime / s_nanosecondsPerSecond;
417 TimeUtil::OpaqueNativeTime now;
419 return (
double)(d_accumulatedWallTime + elapsedWallTime(now))
420 / s_nanosecondsPerSecond;
423 return (
double)d_accumulatedWallTime / s_nanosecondsPerSecond;
440#ifndef BDE_OPENSOURCE_PUBLICATION
Definition bsls_stopwatch.h:149
double accumulatedWallTime() const
Definition bsls_stopwatch.h:414
static const bool k_COLLECT_WALL_TIME_ONLY
Definition bsls_stopwatch.h:207
void stop()
Definition bsls_stopwatch.h:365
void start(bool collectCpuTimes=false)
Definition bsls_stopwatch.h:348
double accumulatedUserTime() const
Definition bsls_stopwatch.h:398
double accumulatedSystemTime() const
Definition bsls_stopwatch.h:382
void accumulatedTimes(double *systemTime, double *userTime, double *wallTime) const
Stopwatch()
Definition bsls_stopwatch.h:323
void reset()
Definition bsls_stopwatch.h:339
double elapsedTime() const
Definition bsls_stopwatch.h:427
static const bool k_COLLECT_WALL_AND_CPU_TIMES
Definition bsls_stopwatch.h:211
bool isRunning() const
Definition bsls_stopwatch.h:433
#define BSLS_IDENT(str)
Definition bsls_ident.h:195
#define BSLS_KEYWORD_DELETED
Definition bsls_keyword.h:609
bsls::Stopwatch bsls_Stopwatch
This alias is defined for backward compatibility.
Definition bsls_stopwatch.h:446
Definition bdlt_iso8601util.h:691
static Types::Int64 convertRawTime(OpaqueNativeTime rawTime)
static Types::Int64 getProcessUserTimer()
static void getTimerRaw(OpaqueNativeTime *timeValue)
static void getProcessTimers(Types::Int64 *systemTimer, Types::Int64 *userTimer)
static Types::Int64 getProcessSystemTimer()
long long Int64
Definition bsls_types.h:132