X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fopenjp2%2Fopj_clock.c;h=24f79a9ae7568e573eef2dae4bb2c738258a30a3;hb=8e6c371e66d9c579048fd336cc3365869486080a;hp=5f2ab9dc0de894d5568de5b66a55260cd8d3f5b4;hpb=44ca89eff7f6054bfdc8f7e688eda3a343569c21;p=openjpeg.git diff --git a/src/lib/openjp2/opj_clock.c b/src/lib/openjp2/opj_clock.c index 5f2ab9dc..24f79a9a 100644 --- a/src/lib/openjp2/opj_clock.c +++ b/src/lib/openjp2/opj_clock.c @@ -1,4 +1,9 @@ /* + * The copyright in this software is being made available under the 2-clauses + * BSD License, included below. This software may be subject to other third + * party and contributor rights, including patent rights, and no such rights + * are granted under this license. + * * Copyright (c) 2005, Herve Drolon, FreeImage Team * All rights reserved. * @@ -24,6 +29,8 @@ * POSSIBILITY OF SUCH DAMAGE. */ +#include "opj_includes.h" + #ifdef _WIN32 #include #else @@ -31,29 +38,30 @@ #include #include #endif /* _WIN32 */ -#include "opj_includes.h" -OPJ_FLOAT64 opj_clock(void) { +OPJ_FLOAT64 opj_clock(void) +{ #ifdef _WIN32 - /* _WIN32: use QueryPerformance (very accurate) */ - LARGE_INTEGER freq , t ; + /* _WIN32: use QueryPerformance (very accurate) */ + LARGE_INTEGER freq, t ; /* freq is the clock speed of the CPU */ QueryPerformanceFrequency(&freq) ; - /* cout << "freq = " << ((double) freq.QuadPart) << endl; */ + /* cout << "freq = " << ((double) freq.QuadPart) << endl; */ /* t is the high resolution performance counter (see MSDN) */ - QueryPerformanceCounter ( & t ) ; - return ( t.QuadPart /(OPJ_FLOAT64) freq.QuadPart ) ; + QueryPerformanceCounter(& t) ; + return ((OPJ_FLOAT64) t.QuadPart / (OPJ_FLOAT64) freq.QuadPart) ; #else - /* Unix or Linux: use resource usage */ + /* Unix or Linux: use resource usage */ struct rusage t; OPJ_FLOAT64 procTime; /* (1) Get the rusage data structure at this moment (man getrusage) */ - getrusage(0,&t); + getrusage(0, &t); /* (2) What is the elapsed time ? - CPU time = User time + System time */ - /* (2a) Get the seconds */ + /* (2a) Get the seconds */ procTime = (OPJ_FLOAT64)(t.ru_utime.tv_sec + t.ru_stime.tv_sec); /* (2b) More precisely! Get the microseconds part ! */ - return ( procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * 1e-6 ) ; + return (procTime + (OPJ_FLOAT64)(t.ru_utime.tv_usec + t.ru_stime.tv_usec) * + 1e-6) ; #endif }