xref: /aosp_15_r20/external/vboot_reference/tests/common/timer_utils.h (revision 8617a60d3594060b7ecbd21bc622a7c14f3cf2bc)
1*8617a60dSAndroid Build Coastguard Worker  /* Copyright 2010 The ChromiumOS Authors
2*8617a60dSAndroid Build Coastguard Worker  * Use of this source code is governed by a BSD-style license that can be
3*8617a60dSAndroid Build Coastguard Worker  * found in the LICENSE file.
4*8617a60dSAndroid Build Coastguard Worker  */
5*8617a60dSAndroid Build Coastguard Worker 
6*8617a60dSAndroid Build Coastguard Worker #ifndef VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_
7*8617a60dSAndroid Build Coastguard Worker #define VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_
8*8617a60dSAndroid Build Coastguard Worker 
9*8617a60dSAndroid Build Coastguard Worker #include <inttypes.h>
10*8617a60dSAndroid Build Coastguard Worker #include <time.h>
11*8617a60dSAndroid Build Coastguard Worker 
12*8617a60dSAndroid Build Coastguard Worker typedef struct ClockTimer {
13*8617a60dSAndroid Build Coastguard Worker 	struct timespec start_time;
14*8617a60dSAndroid Build Coastguard Worker 	struct timespec end_time;
15*8617a60dSAndroid Build Coastguard Worker } ClockTimerState;
16*8617a60dSAndroid Build Coastguard Worker 
17*8617a60dSAndroid Build Coastguard Worker /* Start timer and update [ct]. */
18*8617a60dSAndroid Build Coastguard Worker void StartTimer(ClockTimerState* ct);
19*8617a60dSAndroid Build Coastguard Worker 
20*8617a60dSAndroid Build Coastguard Worker /* Stop timer and update [ct]. */
21*8617a60dSAndroid Build Coastguard Worker void StopTimer(ClockTimerState* ct);
22*8617a60dSAndroid Build Coastguard Worker 
23*8617a60dSAndroid Build Coastguard Worker /* Get duration in milliseconds. */
24*8617a60dSAndroid Build Coastguard Worker uint32_t GetDurationMsecs(ClockTimerState* ct);
25*8617a60dSAndroid Build Coastguard Worker 
26*8617a60dSAndroid Build Coastguard Worker #endif  /* VBOOT_REFERENCE_COMMON_TIMER_UTILS_H_ */
27