File tree Expand file tree Collapse file tree 2 files changed +16
-0
lines changed
criterion-measurement/cbits Expand file tree Collapse file tree 2 files changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -68,6 +68,18 @@ criterion_rdtsc (void)
6868 return result ;
6969}
7070
71+ #elif wasm32_HOST_ARCH
72+
73+ #include <time.h>
74+
75+ StgWord64 criterion_rdtsc (void )
76+ {
77+ struct timespec ts ;
78+ StgWord64 result_stg = 0 ;
79+ clock_gettime (CLOCK_REALTIME , & ts );
80+ result_stg = ts .tv_sec * 1000000000LL + ts .tv_nsec ;
81+ return result_stg ;
82+ }
7183#else
7284
7385#error Unsupported OS/architecture/compiler!
Original file line number Diff line number Diff line change @@ -18,7 +18,11 @@ double criterion_getcputime(void)
1818{
1919 struct timespec ts ;
2020
21+ #ifndef __wasi__
2122 clock_gettime (CLOCK_PROCESS_CPUTIME_ID , & ts );
23+ #else
24+ clock_gettime (CLOCK_REALTIME , & ts );
25+ #endif
2226
2327 return ts .tv_sec + ts .tv_nsec * 1e-9 ;
2428}
You can’t perform that action at this time.
0 commit comments