-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EbTime: Refactor time functions (#120)
Signed-off-by: Christopher Degawa <christopher.degawa@intel.com>
- Loading branch information
Showing
11 changed files
with
246 additions
and
283 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* Copyright(c) 2019 Intel Corporation | ||
* SPDX - License - Identifier: BSD - 2 - Clause - Patent | ||
*/ | ||
|
||
#ifdef _WIN32 | ||
#include <sys/timeb.h> | ||
#include <windows.h> | ||
#elif !defined(__USE_POSIX199309) | ||
#define __USE_POSIX199309 | ||
#endif | ||
|
||
#include <time.h> | ||
|
||
#if !defined(CLOCK_MONOTONIC) && !defined(_WIN32) | ||
#include <sys/time.h> | ||
#endif | ||
|
||
#include "EbAppTime.h" | ||
|
||
void app_svt_vp9_sleep(const unsigned milliseconds) { | ||
if (!milliseconds) return; | ||
#ifdef _WIN32 | ||
Sleep(milliseconds); | ||
#else | ||
nanosleep(&(struct timespec){milliseconds / 1000, | ||
(milliseconds % 1000) * 1000000}, | ||
NULL); | ||
#endif | ||
} | ||
|
||
double app_svt_vp9_compute_overall_elapsed_time( | ||
const uint64_t start_seconds, const uint64_t start_useconds, | ||
const uint64_t finish_seconds, const uint64_t finish_useconds) { | ||
const int64_t s_diff = (int64_t)finish_seconds - (int64_t)start_seconds, | ||
u_diff = (int64_t)finish_useconds - (int64_t)start_useconds; | ||
return ((double)s_diff * 1000.0 + (double)u_diff / 1000.0 + 0.5) / 1000.0; | ||
} | ||
|
||
void app_svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds) { | ||
#ifdef _WIN32 | ||
struct _timeb curr_time; | ||
_ftime_s(&curr_time); | ||
*seconds = curr_time.time; | ||
*useconds = curr_time.millitm; | ||
#elif defined(CLOCK_MONOTONIC) | ||
struct timespec curr_time; | ||
clock_gettime(CLOCK_MONOTONIC, &curr_time); | ||
*seconds = (uint64_t)curr_time.tv_sec; | ||
*useconds = (uint64_t)curr_time.tv_nsec / 1000UL; | ||
#else | ||
struct timeval curr_time; | ||
gettimeofday(&curr_time, NULL); | ||
*seconds = curr_time.tv_sec; | ||
*useconds = curr_time.tv_usec; | ||
#endif | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/* | ||
* Copyright(c) 2019 Intel Corporation | ||
* SPDX - License - Identifier: BSD - 2 - Clause - Patent | ||
*/ | ||
|
||
#ifndef EbAppTime_h | ||
#define EbAppTime_h | ||
|
||
#include <stdint.h> | ||
|
||
void app_svt_vp9_sleep(const unsigned milliseconds); | ||
double app_svt_vp9_compute_overall_elapsed_time(const uint64_t start_seconds, | ||
const uint64_t start_useconds, | ||
const uint64_t finish_seconds, | ||
const uint64_t finish_useconds); | ||
void app_svt_vp9_get_time(uint64_t *const seconds, uint64_t *const useconds); | ||
|
||
#endif // EbAppTime_h |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.