This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Benchmarking SCM_NIMP <--> SCM_NNULLP


Hi,

although this are probably really peanuts I did some benchmarks on the
question whether replacing SCM_NIMP by SCM_NNULLP is performance-safe.  I
used the code below and tried each combination of SCM_NIMP/SCM_NNULLP
and value=SCM_EOL/scm_cons(SCM_EOL,SCM_EOL).

I compiled the whole thing with
> gcc -Wall -O9 test.c `guile-config compile` `guile-config link`
and measured the execution time with
> time ./a.out

The results for my machine (Linux marvin 2.2.13 #1 Mon Nov 8 15:51:29 CET
1999 i586 unknown, 75Mhz) are:


SCM_NIMP(SCM_EOL):
81.610u 0.200s 1:31.19 89.7%    0+0k 0+0io 198pf+0w
82.500u 0.040s 1:26.56 95.3%    0+0k 0+0io 198pf+0w
81.760u 0.050s 1:24.25 97.1%    0+0k 0+0io 198pf+0w
82.470u 0.020s 1:23.88 98.3%    0+0k 0+0io 198pf+0w
81.630u 0.020s 1:22.44 99.0%    0+0k 0+0io 198pf+0w

SCM_NNULLP(SCM_EOL):
81.730u 0.060s 1:22.21 99.4%    0+0k 0+0io 198pf+0w
81.620u 0.060s 1:22.25 99.3%    0+0k 0+0io 198pf+0w
81.300u 0.050s 1:21.35 100.0%   0+0k 0+0io 198pf+0w
81.850u 0.070s 1:25.00 96.3%    0+0k 0+0io 198pf+0w
81.530u 0.090s 1:22.22 99.2%    0+0k 0+0io 198pf+0w


SCM_NIMP(scm_cons):
108.790u 0.120s 1:59.46 91.1%   0+0k 0+0io 198pf+0w
108.770u 0.090s 1:53.84 95.6%   0+0k 0+0io 198pf+0w
110.430u 0.220s 2:01.63 90.9%   0+0k 0+0io 198pf+0w
109.610u 0.110s 1:59.54 91.7%   0+0k 0+0io 198pf+0w
109.300u 0.120s 1:56.10 94.2%   0+0k 0+0io 198pf+0w

SCM_NNULLP(scm_cons):
108.970u 0.120s 1:53.17 96.3%   0+0k 0+0io 237pf+0w
108.480u 0.080s 1:51.49 97.3%   0+0k 0+0io 198pf+0w
108.350u 0.060s 1:49.31 99.1%   0+0k 0+0io 198pf+0w
108.570u 0.070s 1:50.06 98.7%   0+0k 0+0io 198pf+0w
110.190u 0.150s 2:02.16 90.3%   0+0k 0+0io 198pf+0w

Thus, there doesn't seem to be any impact on performance on my
machine.  Sorry that I can't tell about others, but you can try for
yourself.

Best regards,
Dirk Herrmann



#include <stdio.h>
#include <guile/gh.h>


unsigned long test(SCM x, unsigned long y)
{
    if (SCM_NIMP(x))
/*    if (SCM_NNULLP(x)) */
        return y + 1;
    else
        return y + 2;
}


void real_main(int argc, char** argv)
{
    unsigned long count = 0;
    unsigned long result = 0;
    SCM value;

/*    value = SCM_EOL;  */
    value = scm_cons(SCM_EOL, SCM_EOL);
    for (count = 0; count < 0 + 2000000000; ++count)
	result = test(value, result);
    printf("%lu\n", result);
}


int main(int argc, char** argv)
{
    gh_enter(argc, argv, real_main);
    return 0;
}



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]