schell@birch.eecs.ucdavis.edu (Stephan Schell) (05/15/91)
I am having a problem with code that calls sprintf(buf, "%e", a_double_val).
In particular, the results are fine but the execution time is way too high.
I wrote a little program:
#include <stdio.h>
#include <sys/times.h>
main()
{
char buf[80];
struct tms t0, t1;
int i, N;
printf("Enter number of items: ");
scanf("%d", &N);
times( &t0 );
for ( i = 0; i < N; i++ )
sprintf(buf, "%e\n", 3.1415926535897 );
times( &t1 );
printf("CPU seconds %e\n", (t1.tms_utime - t0.tms_utime) * CLK_FAC );
printf("SYS seconds %e\n", (t1.tms_stime - t0.tms_stime) * CLK_FAC );
exit(0);
}
For N = 100000, the results on several different machines are:
NeXT HP 9000/835 DECstation 5000/200
CPU 5.7 12.6 4.2
SYS 684.2 0.03 0.07
For reference, CLK_FAC is 1/60 on the NeXT and the DEC, and 1/100 on the HP.
GCC and cc on the DEC yielded the same results.
WHY IS THE SYS TIME ON THE NEXT SO LARGE? ARGGGHHHH!
I tracked it down as far as I could, to the ecvt routine on the NeXT.
Other floating point stuff seems to run quite fast. The NeXT in question
is an older Cube that has been upgraded to an 040 and 2.0 or 2.1.
Is this NeXT messed up in its ecvt routine or are all NeXTs messed up
this way? Why is ecvt considered (or using) a system call? Am I
completely missing something here?
Thanks,
Steve
--
-------------------------------------------------------------------------------
Dr. Stephan Schell schell@llandru.eecs.ucdavis.edu
Dept. of Electrical Engineering {ucbvax,lll-crg}!ucdavis!llandru!schell
& Compter Science
University of California, Davis (916) 752-1326