mirror of
https://github.com/Unidata/netcdf-c.git
synced 2024-12-27 08:49:16 +08:00
90fd1406bc
Re: GH Issue https://github.com/Unidata/netcdf-c/issues/1900 Apparently the clock_gettime() function is not always available. It is used in unit_test/tst_exhash.c and unit_test/tst_xcache.c. To solve this, a number of things were changed: * Move the timing code to a new file unit_tests/timer_utils.[ch] * Modify the timing code to choose one of several timing methods depending on availability. The prioritized order is as follows: 1. If Windows, use the QueryPerformanceCounter mechanism else 2. Use clock_gettime if available else 3. Use gettimeofday if available else 4. Use getrusage if available Note that the resolution of 3 and 4 is less than 1 or 2. Misc. Other Changes: * Move the test in CMakeLists.txt that disables unit tests for WIN32 to unit_test/CMakeLists.txt since some unit tests actually work under Visual Studio. * Fix some of the unit tests to work under visual studio * Fix problem with using remove() in zmap_nzf.c * Remove some warning about use of EXTERNL
31 lines
922 B
C
31 lines
922 B
C
/*********************************************************************
|
|
* Copyright 2020, UCAR/Unidata
|
|
* See netcdf/COPYRIGHT file for copying and redistribution conditions.
|
|
*********************************************************************/
|
|
|
|
#ifndef TIMER_UTILS_H
|
|
#define TIMER_UTILS_H 1
|
|
|
|
#include "netcdf.h"
|
|
|
|
/* Wrap time interval computations */
|
|
typedef struct Nanotime {
|
|
long long tv_sec; /* seconds */
|
|
long long tv_nsec; /* nanoseconds */
|
|
} Nanotime;
|
|
|
|
|
|
struct TimeRange {
|
|
long long min;
|
|
long long max;
|
|
};
|
|
|
|
extern void NCT_inittimer(void);
|
|
extern void NCT_marktime(Nanotime* nt);
|
|
extern void NCT_elapsedtime(Nanotime* nt0, Nanotime* nt1, Nanotime* delta);
|
|
extern int NCT_reporttime(unsigned count, Nanotime* times, struct TimeRange, const char* tag);
|
|
extern long long NCT_nanoseconds(Nanotime time);
|
|
extern int NCT_rangetest(long long nsecs, struct TimeRange range);
|
|
#endif /*TIMER_UTILS_H*/
|
|
|