mini benchmark vtim formatting
Poul-Henning Kamp
phk at phk.freebsd.dk
Mon Oct 8 09:07:47 UTC 2018
--------
In message <6e3db4b7-5817-4c60-8c20-f4dce1ebf9d1 at schokola.de>, Nils Goroll writes:
>> printf("%ju.%06ju",
>> (uint64_t)floor(foo),
>> (uint64_t)floor((foo*1e6)) % 1000000UL);
>
>nice trick. On Linux, this gets us down to the same order of magnitude as a
>%lu.%06lu with uint64_t
The important thing here is the FP rendering, not the FP math, which is
instantaneous for all practical purposes.
It's kind of surprising to me that "%.<N>f" hasn't gotten specific
optimization, it is a lot simpler thing than the general FP formatting
problem, but if there is any code I'm not keen on wading into, it is
FP formatting code...
--
Poul-Henning Kamp | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG | TCP/IP since RFC 956
FreeBSD committer | BSD since 4.3-tahoe
Never attribute to malice what can adequately be explained by incompetence.
More information about the varnish-dev
mailing list