]>
git.saurik.com Git - apple/icu.git/blob - icuSources/test/usetperf/timer.h
2 **********************************************************************
3 * Copyright (c) 2002-2004, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * 2002-09-20 aliu Created.
8 #ifndef __PERFTIMER_H__
9 #define __PERFTIMER_H__
11 #include "unicode/utypes.h"
13 // Derived from Ram's perftime.h
15 //----------------------------------------------------------------------
18 #if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)
23 LARGE_INTEGER tstart
, tend
;
27 QueryPerformanceCounter(&tstart
);
29 inline double stop() {
30 QueryPerformanceCounter(&tend
);
32 int result
= QueryPerformanceFrequency(&freq
);
33 return ((double)(tend
.QuadPart
- tstart
.QuadPart
))/((double)freq
.QuadPart
);
37 //----------------------------------------------------------------------
45 struct timeval tstart
, tend
;
50 gettimeofday(&tstart
, &tz
);
52 inline double stop() {
53 gettimeofday(&tend
, &tz
);
55 t1
= (double)tstart
.tv_sec
+ (double)tstart
.tv_usec
*1e-6;
56 t2
= (double)tend
.tv_sec
+ (double)tend
.tv_usec
*1e-6;