Stopwatch

Overview

Functions for time measurement

Copyright (C) 2004-2022 OKTET Labs Ltd. More…

// typedefs

typedef struct te_stopwatch_t te_stopwatch_t;

// structs

struct te_stopwatch_t;

// global functions

te_errno te_stopwatch_start(te_stopwatch_t* stopwatch);
te_errno te_stopwatch_stop(te_stopwatch_t* stopwatch, struct timeval* lap);

// macros

#define TE_STOPWATCH_INIT

Detailed Documentation

Functions for time measurement

Copyright (C) 2004-2022 OKTET Labs Ltd. All rights reserved.

Example of usage

Let’s assume we need to measure some routine duration

#include "te_stopwatch.h"

te_stopwatch_t stopwatch = TE_STOPWATCH_INIT;
struct timeval duration;

CHECK_RC(te_stopwatch_start(&stopwatch));
RING("Some routine");
CHECK_RC(te_stopwatch_stop(&stopwatch, &duration));

Typedefs

typedef struct te_stopwatch_t te_stopwatch_t

Stopwatch context

Global Functions

te_errno te_stopwatch_start(te_stopwatch_t* stopwatch)

Start stopwatch. It does not care if the stopwatch is already started, it will restart it.

Parameters:

stopwatch

Stopwatch handle

Returns:

Status code

te_errno te_stopwatch_stop(te_stopwatch_t* stopwatch, struct timeval* lap)

Stop stopwatch and calculate its duration

Parameters:

stopwatch

Stopwatch handle

lap

Overall time of stopwatch job

Returns:

Status code

Macros

#define TE_STOPWATCH_INIT

On-stack stopwatch context initializer