To Bill:
1. Benchmarking in interpreter is meaningless, I'm sure
you noticed that you can do 10^6 calls in interpreter in 4s
while do 2*10^8 calls in 0.4s in compiler.
2. The FriCAS you are using should be built from my branch,
to have the inline patch, so that functions from Maybe can be inlined.
3. I didn't include array generation code in test function,
(although it didn't matter much in this case, just my habit)
so the first call from the benchmark package will generate the
array so it should not be timed. I also use 'qelt' to avoid
checking index.
4. I use "failed2?" to represent the "generic" Maybe case:
Qfailed ==> _*MAYBEFAIL_*$Lisp
Qfailed2 := GENSYM()$Lisp pretend %
failed? x == EQ(x, Qfailed)$Lisp
failed2? x == EQ(x, Qfailed2)$Lisp
--- Maybe benchmark package
)abbrev package TESTM TestMaybe
TestMaybe() : Exp == Imp where
Exp == with
f1 : Integer -> Integer
f2 : Integer -> Integer
f3 : Integer -> Integer
Imp == add
NNI ==> NonNegativeInteger
import from Vector NNI
v1 : Vector Maybe NNI := new(10^6, failed())
v2 : Vector Union(NNI, "failed") := new(10^6, "failed")
f1 x ==
v := v1
for j in 1..x repeat
for i in 1..10^6 repeat
failed? qelt(v, i)
x
f2 x ==
v := v1
for j in 1..x repeat
for i in 1..10^6 repeat
failed2? qelt(v, i)
x
f3 x ==
v := v2
for j in 1..x repeat
for i in 1..10^6 repeat
qelt(v, i) case "failed"
x
----- benchmark result
-- compile maybe to make "failed2?" available
(1) -> )co maybe
(1) -> )co bench-maybe
(1) -> )time on
(1) -> f1 1; -- to init the array
(2) -> f1 200;
Time: 0.39 (EV) = 0.39 sec
(3) -> f2 200;
Time: 0.00 (IN) + 1.22 (EV) + 0.00 (OT) = 1.23 sec
(4) -> f3 200;
Time: 0.40 (EV) = 0.40 sec
--
You received this message because you are subscribed to the Google Groups
"FriCAS - computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/fricas-devel.
For more options, visit https://groups.google.com/d/optout.