Posts Tagged ‘testing’

More testing

3 September 2008

I wrote a slightly more interesting program called IntersectSquares, which generates an array of a large number of rectangles, then counts how many times they intersect each other. This is written in a fairly naive way, so there are a fair few expression for the optimiser to move out of the loop. I tried it here with 100,000 rectangles:

With jkit:

andrew@rise:test cases$ time java IntersectSquares; time java IntersectSquares
3290 intersections

real 0m58.843s
user 0m58.470s
sys 0m0.020s
3290 intersections

real 0m58.918s
user 0m58.491s
sys 0m0.040s

With javac:

andrew@rise:test cases$ time java IntersectSquares; time java IntersectSquares; time java IntersectSquares
3290 intersections

real 1m4.690s
user 1m3.783s
sys 0m0.030s
3290 intersections

real 1m4.908s
user 1m3.805s
sys 0m0.051s
3290 intersections

real 1m4.209s
user 1m3.695s
sys 0m0.041s

Advertisements

You are doing it wrong…

21 August 2008

SimpleLisp is an interpreter, written in Java, for a limited dialect of LISP. I have been using it as an example Java program to evaluate my compiler optimisations. I just tried running a simple Lisp program (to calculate the Fibonacci sequence) in SimpleLisp to see the affect of my optimisations on the run time. Here are some results.

SimpleLisp compiled with jkit, without my optimisation stage:

$ time java org/simplelisp/interpreter/Interpreter examples/Fibonacci.sl
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393

real 0m3.380s
user 0m3.294s
sys 0m0.031s

SimpleLisp compiled with jkit, with my LICM optimisation stage:

$ time java org/simplelisp/interpreter/Interpreter examples/Fibonacci.sl
1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765 10946 17711 28657 46368 75025 121393

real 0m4.289s
user 0m4.136s
sys 0m0.051s

Something is not quite right here…

Corpus

16 June 2008

So I need to evaluate the optimisations I have so far. It has been suggested by Dave that his SimpleLisp interpreter and the JKit parser might make good tests.

I have had a look through SimpleLisp, and though there are a number of places where methods like List.size() are called inside loops, none of the classes in question are immutable. It thus seems that it will be necessary to implement the next stage of the optimiser (checking whether anything in the loop body will change the object in question) before any useful optimisation can be performed, in this program at least. This is fairly much what I expected, and likely to be the case in many programs.