Java Mailing List Archive

http://www.redhatconfig.com/

Home » Red Hat Enterprise Linux 5 »

[rhelv5-list] Performance issue & test case

Pedro Espinoza

2008-02-18

Replies:

Author LoginPost Reply
Hi Listers:

The program appended below takes almost 9 minutes on RHEL 5, RHEL5.1,
latest RHEL 4, Centos5.1. However, the same program takes 2m 15
seconds on OPensuse 10.2 (2.6.18.8 kernel), and on Fedora 8. The box
has 4 dual-core xeon processors, and with 8 GB memory.


However, the same program takes 2min 45s on a box that has one
dual-core opteron, with RHEL 4 ( 2.6.9-42.0.2.ELsmp SMP).

Any pointers appreciated.

Thanks, Pedro,




/* compile: cc sorttest.c -O3 -lm -o sorttest */
/* Run: ./sorttest 20 */
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define N 10000000 /* vector of 10-M */

int scr[N], i, cnt, n, posx[N], srt_f(const void *, const void *);

double a, aaa, posy[N];

int srt_f(const void *a, const void *b)
{ aaa = posy[*((int *)a)] - posy[*((int *)b)];
if ( aaa < 0. ) return(-1);
return( aaa > 0. ); }

int main(int argc, char *argv[])
{ cnt = ( argc == 1 ) ? 1 : atoi(argv[1]);
for ( n = 0; n < cnt; ++n )
{ for ( i = 0; i < N; ++i )
  { posx[i] = i;
   a += .001;
   posy[i] = sin(a); }
  qsort((void *) posx, i, sizeof(i), srt_f);
  for ( i = 0; i < N; ++i )
   scr[posx[i]] = (1000*i)/N; } }

_______________________________________________
rhelv5-list mailing list
rhelv5-list@(protected)
https://www.redhat.com/mailman/listinfo/rhelv5-list
©2008 redhatconfig.com - Jax Systems, LLC, U.S.A.