Re: Fastest way to determine number is integer in plain Lua
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Fastest way to determine number is integer in plain Lua
- From: "Alexander Gladysh" <agladysh@...>
- Date: Sat, 8 Nov 2008 20:41:14 +0300
>> -----------------------------------------------------------------------------
>> name | rel | delta | abs / iter = ms per iteration
>>
>> -----------------------------------------------------------------------------
>> noop_int | 1.0000 | 0.0000 | 8.83 / 50000000 = 0.176600
>> ms
>> ...
>
> A minor problem... my brain keeps on doing a mental double-take whenever I
> see "ms", because I keep interpreting that as milliseconds. "ns" might be
> easier for the brain to interpret, because for microseconds, one must
> compare fractions, while for nanoseconds, one can look at the integer
> portion and quickly get an idea of its magnitude. But it's a minor thing.
I've changed ms in the script output to the less ambiguous us -- it is closer to the µ (mu) letter for the microseconds. Hopefully it would help.
> Thanks again for keeping the list supplied with benchmark data!
You're welcome. I'm glad you're interested! :-)
BTW, here are the results of the last benchmark with 1e9 iterations. (I replaced us to µs here.)
lua-------------------------------------------------------------------
name | rel | abs s / iter = µs (1e-6 s) / iter
-------------------------------------------------------------------
mod_int | 1.0000 | 220.20 / 1000000000 = 0.220200
µs
bits_int_direct | 1.0038 | 221.04 / 1000000000 = 0.221040
µs
mod_int_direct | 1.0088 | 222.14 / 1000000000 = 0.222140
µs
mod_nonint_direct | 1.0308 | 226.98 / 1000000000 = 0.226980
µs
mod_nonint | 1.0325 | 227.36 / 1000000000 = 0.227360
µs
bits_nonint | 1.0482 | 230.81 / 1000000000 = 0.230810
µs
bits_nonint_direct | 1.0559 | 232.52 / 1000000000 = 0.232520
µs
bits_int | 1.0757 | 236.86 / 1000000000 = 0.236860
µs
floor_nonint_direct | 1.4797 | 325.83 / 1000000000 = 0.325830
µs
floor_int | 1.5225 | 335.25 / 1000000000 = 0.335250
µs
floor_nonint | 1.5365 | 338.34 / 1000000000 = 0.338340
µs
floor_int_direct | 1.5404 | 339.20 / 1000000000 = 0.339200
µs
luajit -O
-------------------------------------------------------------------
name | rel | abs s / iter =
µs (1e-6 s) / iter
-------------------------------------------------------------------
bits_int | 1.0000 | 28.36 / 1000000000 = 0.028360
µs
bits_int_direct | 1.1185 | 31.72 / 1000000000 = 0.031720
µs
bits_nonint_direct | 1.1308 | 32.07 / 1000000000 = 0.032070
µs
bits_nonint | 1.1590 | 32.87 / 1000000000 = 0.032870
µs
mod_int | 1.1862 | 33.64 / 1000000000 = 0.033640
µs
mod_nonint | 1.2895 | 36.57 / 1000000000 = 0.036570
µs
mod_int_direct | 1.3258 | 37.60 / 1000000000 = 0.037600
µs
mod_nonint_direct | 1.3385 | 37.96 / 1000000000 = 0.037960
µs
floor_nonint | 1.4721 | 41.75 / 1000000000 = 0.041750
µs
floor_int | 1.4746 | 41.82 / 1000000000 = 0.041820
µs
floor_nonint_direct | 1.6255 | 46.10 / 1000000000 = 0.046100
µs
floor_int_direct | 1.7059 | 48.38 / 1000000000 = 0.048380
µs
On plain Lua there is not much difference between a%1 and 2^52 versions. Also direct and indirect versions are clearly almost identical, and the difference between them is too close to the measurement error to be relevant.
Alexander.