mirror of
https://github.com/wolfSSL/wolfssl.git
synced 2025-07-30 18:57:27 +02:00
gettime_secs() in api.c now uses TimeNowInMilliseconds()
This commit is contained in:
25
tests/api.c
25
tests/api.c
@ -66387,28 +66387,7 @@ static const char* apitest_res_string(int res)
|
|||||||
#ifndef WOLFSSL_UNIT_TEST_NO_TIMING
|
#ifndef WOLFSSL_UNIT_TEST_NO_TIMING
|
||||||
static double gettime_secs(void)
|
static double gettime_secs(void)
|
||||||
{
|
{
|
||||||
#if defined(_MSC_VER) && defined(_WIN32)
|
return (double)(TimeNowInMilliseconds() / 1000.0);
|
||||||
{
|
|
||||||
/* there's no gettimeofday for Windows, so we'll use system time */
|
|
||||||
#define EPOCH_DIFF 11644473600LL
|
|
||||||
FILETIME currentFileTime;
|
|
||||||
GetSystemTimePreciseAsFileTime(¤tFileTime);
|
|
||||||
|
|
||||||
ULARGE_INTEGER uli = { 0, 0 };
|
|
||||||
uli.LowPart = currentFileTime.dwLowDateTime;
|
|
||||||
uli.HighPart = currentFileTime.dwHighDateTime;
|
|
||||||
|
|
||||||
/* Convert to seconds since Unix epoch */
|
|
||||||
return (double)((uli.QuadPart - EPOCH_DIFF * 10000000) / 10000000);
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
{
|
|
||||||
struct timeval tv;
|
|
||||||
LIBCALL_CHECK_RET(gettimeofday(&tv, 0));
|
|
||||||
|
|
||||||
return (double)tv.tv_sec + (double)tv.tv_usec / 1000000;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -66478,7 +66457,7 @@ int ApiTest(void)
|
|||||||
#endif
|
#endif
|
||||||
#ifndef WOLFSSL_UNIT_TEST_NO_TIMING
|
#ifndef WOLFSSL_UNIT_TEST_NO_TIMING
|
||||||
if (ret != TEST_SKIPPED) {
|
if (ret != TEST_SKIPPED) {
|
||||||
printf(" %s (%9.5lf)\n", apitest_res_string(ret), timeDiff);
|
printf(" %s (%9.3lf)\n", apitest_res_string(ret), timeDiff);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
|
Reference in New Issue
Block a user