Path: blob/main/test/emscripten_performance_now.c
7085 views
#include <emscripten/html5.h>1#include <emscripten/threading.h>2#include <assert.h>3#include <stdio.h>45double performanceNow;6double dateNow;78void test(void *userData) {9double now2 = emscripten_performance_now();10assert(now2 >= performanceNow + 100);1112double now3 = emscripten_date_now();13assert(now3 >= dateNow + 100);1415printf("done\n");16exit(0);17}1819int main() {20performanceNow = emscripten_performance_now();21assert(performanceNow < 10*1000); // Should take well less than 10 seconds to load up the page2223dateNow = emscripten_date_now();24assert(dateNow > 1547568082); // == 2019-01-15T16:01:22+00:00)2526#ifdef __EMSCRIPTEN_PTHREADS__27emscripten_thread_sleep(200);28test(0);29#else30emscripten_set_timeout(test, 200, 0);31#endif3233return 99;34}353637