| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the Chromium LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef TESTS_TIMING_H | 
|  | 6 #define TESTS_TIMING_H | 
|  | 7 | 
|  | 8 #include <assert.h> | 
|  | 9 #if defined(_WIN32) | 
|  | 10 #include <windows.h> | 
|  | 11 #else | 
|  | 12 #include <sys/time.h> | 
|  | 13 #endif | 
|  | 14 #include <time.h> | 
|  | 15 | 
|  | 16 #if defined(_WIN32) | 
|  | 17 | 
|  | 18 static double seconds() | 
|  | 19 { | 
|  | 20     static double clock_frequency; | 
|  | 21     static bool have_frequency; | 
|  | 22 | 
|  | 23     LARGE_INTEGER qpc; | 
|  | 24     QueryPerformanceCounter(&qpc); | 
|  | 25     if (have_frequency) | 
|  | 26         return qpc.QuadPart * clock_frequency; | 
|  | 27 | 
|  | 28     have_frequency = true; | 
|  | 29     QueryPerformanceFrequency(&qpc); | 
|  | 30     clock_frequency = 1.0 / (double) qpc.QuadPart; | 
|  | 31     return seconds(); | 
|  | 32 } | 
|  | 33 | 
|  | 34 #else | 
|  | 35 | 
|  | 36 static double seconds() | 
|  | 37 { | 
|  | 38     struct timeval now; | 
|  | 39     gettimeofday(&now, 0); | 
|  | 40     return now.tv_sec + now.tv_usec * (1.0 / 1000000.0); | 
|  | 41 } | 
|  | 42 | 
|  | 43 #endif | 
|  | 44 | 
|  | 45 #define TIME(function, time) do {  \ | 
|  | 46     double start = seconds();      \ | 
|  | 47     (function);                    \ | 
|  | 48     *time += seconds() - start;    \ | 
|  | 49 } while (0) | 
|  | 50 | 
|  | 51 #endif // TESTS_TIMING_H | 
| OLD | NEW | 
|---|