summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/ui/util.c13
-rw-r--r--src/ui/util.h16
2 files changed, 29 insertions, 0 deletions
diff --git a/src/ui/util.c b/src/ui/util.c
index c2bc8f08..5327e103 100644
--- a/src/ui/util.c
+++ b/src/ui/util.c
@@ -3042,3 +3042,16 @@ iWidget *makeTranslation_Widget(iWidget *parent) {
3042 setupSheetTransition_Mobile(dlg, iTrue); 3042 setupSheetTransition_Mobile(dlg, iTrue);
3043 return dlg; 3043 return dlg;
3044} 3044}
3045
3046void init_PerfTimer(iPerfTimer *d) {
3047 d->ticks = SDL_GetPerformanceCounter();
3048}
3049
3050uint64_t elapsedMicroseconds_PerfTimer(const iPerfTimer *d) {
3051 const uint64_t now = SDL_GetPerformanceCounter();
3052 return (uint64_t) (((double) (now - d->ticks)) / (double) SDL_GetPerformanceFrequency() * 1.0e6);
3053}
3054
3055void print_PerfTimer(const iPerfTimer *d, const char *msg) {
3056 printf("[%s] %llu \u03bcs\n", msg, (unsigned long long) elapsedMicroseconds_PerfTimer(d));
3057}
diff --git a/src/ui/util.h b/src/ui/util.h
index f64fac7e..94e5d8bd 100644
--- a/src/ui/util.h
+++ b/src/ui/util.h
@@ -316,3 +316,19 @@ iWidget * makeTranslation_Widget (iWidget *parent);
316 316
317const char * languageId_String (const iString *menuItemLabel); 317const char * languageId_String (const iString *menuItemLabel);
318int languageIndex_CStr (const char *langId); 318int languageIndex_CStr (const char *langId);
319
320/*-----------------------------------------------------------------------------------------------*/
321
322iDeclareType(PerfTimer)
323
324struct Impl_PerfTimer {
325 uint64_t ticks;
326};
327
328void init_PerfTimer (iPerfTimer *);
329uint64_t elapsedMicroseconds_PerfTimer (const iPerfTimer *);
330void print_PerfTimer (const iPerfTimer *, const char *msg);
331
332#define start_PerfTimer(name) iPerfTimer _##name##_PerfTimer; init_PerfTimer(&_##name##_PerfTimer)
333#define stop_PerfTimer(name) print_PerfTimer(&_##name##_PerfTimer, #name)
334