zzaappp |
11-10-2008 03:54 PM |
Kernel performance test (the TICKS test)
I have a performance test I've been running against a collection of kernels in order to find the fastest commercially provided distro out there. So far the fastest I've found has been the Gentoo distro, but that one can take a lot of effort to set up on new hardware.
I wrote a TICKS test to examine how fast and accurate the kernel is at waking up processes from a sleeping state.
Here is the code to ticks.c:
Code:
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <sys/time.h>
#include <sys/timeb.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/times.h>
#include <signal.h>
#include <errno.h>
unsigned long milsec(void)
{
struct timeval tv;
struct timezone tz;
if( gettimeofday( &tv,&tz ) == -1 )
return( 0 );
return( tv.tv_usec + (tv.tv_sec*1000*1000));
}
const char* uname(void)
{
static char buff[1024];
FILE* fp=fopen("/proc/version","r");
if( fp==NULL )
return( "(OS unknown)" );
fgets(buff,sizeof(buff),fp);
return( buff );
}
int main(int argc,char *argv[])
{
volatile char B1[102400];
volatile char B2[102400];
volatile unsigned long Start,Stop;
volatile int count,max=1000,index;
struct timeval tv;
struct timespec tvp;
if( argc >=2 )
max = atoi(argv[1]);
printf("OS: %s\n",uname());
Start = milsec();
for(count=0; count<max; ++count)
{
tv.tv_sec = 0;
tv.tv_usec = 1;
select(0,NULL,NULL,NULL,&tv);
}
Stop = milsec();
printf("TICK : Iterations[%d] Delta[%10lu] Avg[%7.3f]\n",max,Stop-Start,(double)(Stop-Start)/(double)(max));
Start = milsec();
for(count=0; count<max; ++count)
{
tvp.tv_sec = 0;
tvp.tv_nsec = 1;
pselect(0,NULL,NULL,NULL,&tvp,NULL);
}
Stop = milsec();
printf("TICKp : Iterations[%d] Delta[%10lu] Avg[%7.3f]\n",max,Stop-Start,(double)(Stop-Start)/(double)(max));
////////////////////////////////////////
// BENCH of memcpy/indexing
////////////////////////////////////////
Start = milsec();
for(count=0; count<max; ++count)
{
for(index=0; index<sizeof(B1); ++index)
B2[index] = B1[index];
}
Stop = milsec();
printf("MEMCPY: Iterations[%d] Delta[%10lu] Avg[%7.3f]\n",max,Stop-Start,(double)(Stop-Start)/(double)(max));
}
If you save the above code snippet into the file, ticks.c, you can then build and run it with:
Code:
$ gcc ticks.c
$ a.out
I was hoping some Slackware folks out there could run this and add your results to this thread so I can know how the different permutations of the Slackware distro perform. To start, here are my Gentoo stats:
Quote:
Linux foghorn 2.6.20-gentoo-r8 #1 Tue Jul 17 10:48:20 EDT 2007 x86_64 AMD Athlon(tm) 64 FX-55 Processor AuthenticAMD GNU/Linux
TICKS : Iterations[1000] Delta[ 255] Avg[ 0.255]
|
I really appreciate any assistance with this!
-z
|