Subject: Re: Please help me tune NetBSD for bulk.fefe.de/scalability/
To: Felix von Leitner <felix-benchmark@fefe.de>
From: Niels Provos <provos@citi.umich.edu>
List: tech-perform
Date: 10/27/2003 12:21:03
Here is the benchmark that I used way back to measure performance of
file descriptor allocation. Hope it helps.
Niels.
#include <stdio.h>
#include <fcntl.h>
#include <sys/time.h>
#include <sys/resource.h>
#define NFILES 60000
#define TRIALS 10000L
int files[NFILES];
#define ssec ru_stime.tv_sec
#define usec ru_utime.tv_sec
#define susec ru_stime.tv_usec
#define uusec ru_utime.tv_usec
void
massage (int fd)
{
u_long i;
struct rusage t1, t2;
getrusage(RUSAGE_SELF, &t1);
for (i = 0; i < TRIALS; i++) {
close (files[0]);
close (files[fd]);
files[0] = open("/etc/passwd", O_RDONLY, 0);
if (files[0] == -1) {
perror("massage: open(0)");
exit (0);
}
files[fd] = open("/etc/passwd", O_RDONLY, 0);
if (files[fd] == -1) {
perror("massage: open");
exit (0);
}
}
getrusage(RUSAGE_SELF, &t2);
printf ("%d %lf\n", fd, (double)(t2.ssec + t2.usec - t1.ssec - t1.usec) +
(double)(t2.susec + t2.uusec - t1.susec - t1.uusec)/1000000);
}
int
main (void)
{
int i;
for (i = 0; i < NFILES; i++) {
files[i] = open("/etc/passwd", O_RDONLY, 0);
printf ("%d: %d\n", i, files[i]);
if (files[i] == -1) {
perror("open");
exit (0);
}
}
for (i = 1; i < NFILES; i += 2000)
massage (i);
return 1;
}