Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions VM/src/lperf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@
#include <mach/mach_time.h>
#endif

#ifdef __EMSCRIPTEN__
#include <emscripten/emscripten.h>
#endif

#include <time.h>

Expand All @@ -32,6 +35,8 @@ static double clock_period()
return double(result.numer) / double(result.denom) * 1e-9;
#elif defined(__linux__) || defined(__FreeBSD__)
return 1e-9;
#elif defined(__EMSCRIPTEN__)
return 1e-3;
#else
return 1.0 / double(CLOCKS_PER_SEC);
#endif
Expand All @@ -49,6 +54,8 @@ static double clock_timestamp()
timespec now;
clock_gettime(CLOCK_MONOTONIC, &now);
return now.tv_sec * 1e9 + now.tv_nsec;
#elif defined(__EMSCRIPTEN__)
return emscripten_get_now();
#else
return double(clock());
#endif
Expand Down