Hi Tomas,
> >> > java wl ErsatzLisp Pil32 Pil64
> >> > +---------------------------------------
> >> > (fibo 22) | 25 0.19 0.015 0.016
> >> > (fibo 23) | 45 0.25 0.026 0.024
> >> > (fibo 24) | 69 0.36 0.041 0.039
> >> > (fibo 25) | 122 0.52 0.060 0.063
>
> I'm surprised that pil32 performs the same as pil64 even though it
> doesn't have short numbers.
Yes, for small arguments the times are nearly the same. For larger
arguments, fibo on Pil64 is about twice as fast as on Pil32.
> While we are discussing this microbenchmark, I was curious how does
> picolisp compare to Lua:
>
> | | pil64-3.0.4 | lua-5.1 | luajit-2.0.0 | c -O2 |
> |---------+-------------+---------+--------------+-------|
> | fibo 25 | 0.02 | 0.02 | 0.01 | |
> | fibo 30 | 0.16 | 0.18 | 0.08 | |
> | fibo 40 | 19.54 | 22.32 | 8.78 | 1.30 |
>
> What about implementing JIT for picolisp? ;-D
Hehe, tempting. But no way ;-)
> I was also surprised that changing:
>
> (de fibo (N)
> (if (> 2 N)
> 1
> (+ (fibo (dec N)) (fibo (- N 2))) ) )
>
> to
>
> (de fibo (N)
> (if (< N 3)
> N
> (+ (fibo (dec N)) (fibo (- N 2))) ) )
>
> had such significant effect. The version with (> 2 N) is much slower:
>
> | | pil64-3.0.4 |
> |---------+-------------|
> | fibo 25 | 0.03 |
> | fibo 30 | 0.27 |
> | fibo 40 | 31.08 |
This is no wonder. The algorithms are not the same.
If you count the calls
(zero A)
(de f1 (N)
(inc 'A) # Count the calls of 'f1'
(if (> 2 N)
1
(+ (f1 (dec N)) (f1 (- N 2))) ) )
(zero B)
(de f2 (N)
(inc 'B) # Count the calls of 'f2'
(if (< N 3)
N
(+ (f2 (dec N)) (f2 (- N 2))) ) )
(f1 30)
-> 1346269
(f2 30)
-> 1346269
A
-> 2692537
B
-> 1664079
you see that 'f1' is more often called than 'f2' (for the same result).
Cheers,
- Alex
--
UNSUBSCRIBE: mailto:[email protected]?subject=unsubscribe