This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Benchmarks for GUILE?
- To: guile at sourceware dot cygnus dot com
- Subject: Re: Benchmarks for GUILE?
- From: "C. Ray C." <crayc at tomcramer dot org>
- Date: Wed, 15 Mar 2000 12:34:17 -0600
- References: <14543.33191.599595.487038@dokkum.cs.uu.nl>
On Wed, Mar 15, 2000 at 01:27:19PM +0100, Han-Wen Nienhuys wrote:
> [I just had the idea that GUILE spends a significant amount of time
> chasing around linked lists. If SCM_EOL were defined as 0, loops like
> these
>
> for (SCM s = x ; s != SCM_EOL; s = gh_cdr (s))
> .. ;
>
> might be a little faster. On the other hand, the time needed for
> comparing s with SCM_EOL is probably neglible with the rest of
> GUILE. So how do I test?]
To test it, you take the code you want to test, run it a billion times
and time it =^D. gprof is useful here.
I would be surprised if it went faster... I am not completely sure about
other processors, but on x86, there is no difference between comparing
to 0 and comparing to any other value (well, on the 386 there might be
a difference, but they're a rare case nowadays).
It would be the difference between something like this:
testl %eax, %eax
jz end_list
and this:
cmpl %eax, SCM_EOL
je end_list
cmp and test take the same amount of time. je and jz are actually the
same instruction. The first one would be smaller by 3 or 4 bytes however,
since there's no immediate.
If I were to try to speed up searching through lists, I would probably
look into cache misses. If the pairs are far enough apart that would
reduce performance considerably. Maybe in certain cases you could have a
list stored in an array.