use monotonic, higher resolution jiffies#1141
Conversation
| // :note could use errno, here | ||
| if (err) | ||
| return sexp_user_exception(ctx, self, "couldn't get current jiffy", SEXP_FALSE); | ||
| return sexp_make_fixnum(1000000000*tv.tv_sec + tv.tv_nsec); |
There was a problem hiding this comment.
Hmmm... on a 32-bit system, this overflows after the system has been up for 4 seconds.
You could check and make a bignum as needed, but that becomes always on 32-bit systems. Probably better to conditionally define jiffies-per-second as a smaller value, say millisecond granularity, on 32-bit systems.
There was a problem hiding this comment.
Yep. I'll polish up a patch for it tomorrow.
A millisecond is an awfully long time. But nothing better to be done within the constraints of the spec.
There was a problem hiding this comment.
Keep using chibi, you'll come to think a millisecond is fast! 😉
There was a problem hiding this comment.
patched and pushed. hopefully I didn't whiff an ifdef.
|
I don't know why the CMAKE builds decided to all explode; not clear its from my change? |
| LARGE_INTEGER frequency; | ||
| QueryPerformanceFrequency(&frequency); | ||
| return sexp_make_fixnum(frequency.QuadPart); | ||
| #elif !defined(PLAN9) |
There was a problem hiding this comment.
This is the same as the next branch, you can unify them.
| if (err) | ||
| return sexp_user_exception(ctx, self, "couldn't get current jiffy", SEXP_FALSE); | ||
| uint64_t current_ns = 1000000000*tv.tv_sec + tv.tv_nsec; | ||
| #if SEXP_MS_JIFFY |
There was a problem hiding this comment.
This block is repeated below, you can move it out of the current_ns computation just once at the end.
The current-jiffy was 1:1 with current-second, but assuming that its meant to be used more for measuring intervals and not wall time, I replaced it with more suitable clocks:
nsec. they havecycles, but its not a clock out of the box.I haven't tested the windows or plan9 code, but it looks sane to me. Advice on cross-compiling from linux to windows appreciated. I couldn't bring myself to install mingw under wine, but I also couldn't get
make CC=mingw... PLATFORM=windowsto Just Work.