Re: Timings for optimised poll(2)

Rogier Wolff (R.E.Wolff@BitWizard.nl)
Sat, 23 Aug 1997 18:52:56 +0200 (MET DST)


Richard Gooch wrote:
> Timings for 1021 file descriptors on a Pentium 100. These numbers look
> quite promising!

My computer (*) scans 10000 (tenthousand) bits in 15 us. Now
what were you trying to optimize?

Roger.

(*) PPro/150, my 486/66 takes 90 us for those 10000 bits.

/* findbit.c -- Benchmark the find_first_zero_bit routine */
/* Compile with: gcc -Wall -O2 -o findbit findbit.c */
#include <asm/bitops.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/time.h>
#include <unistd.h>

int main (int argc,char **argv)
{
int *p;
int size;
int i,t;
struct timeval start, stop;
int dt;

size = atoi (argv[1]);

p = malloc (size / 8);

for (i=0;i<size/32;i++)
p[i] = -1;

p[size/32-1] = ~1024;

gettimeofday (&start, NULL);
t = find_first_zero_bit (p, size);
gettimeofday (&stop, NULL);

dt = (stop.tv_sec - start.tv_sec) * 1000000 +
(stop.tv_usec - start.tv_usec);
printf ("Found zero bit at %d in %d us.\n", t, dt);
exit (0);
}