Roger Smith <ACPS5788@Ryerson.Ca> (03/23/91)
Hi I am in the process of writing a network simulation program which will have 15 nodes and run .. until a steady state is assumed. I have both Think C and MPW C and have been trying various things under both,The Code i am including was run under both systems and the timings noted. The results seem to indicate that Think C runs faster am I doing something wrong? Why is there such a large Difference in the Loop Times? I am using the CC script file from the Macintosh Programmers WorkShop. Any Feedback is appreciated. # Example 8-6: cc comand file # Compiles and links a C program that runs under the MPW # shell # syntax: # cc -o toolname file.c # If {#} != 3 || "{1}" != "-o" ||6 "{2}" =~ /%-E/ || "{3}"=~ /%-E/ Echo "### {0} - Wrong parameters." Echo "# Usage - {0} -o toolname file.c" Exit 1 End Set CLibs "{CLibraries}CRuntime.o"6 " {CLibraries}StdCLib.o"6 " {CLibraries}CInterface.o"6 " {CLibraries}ToolLibs.o"6 " {CLibraries}CSANELib.o"6 " {CLibraries}Interface.o" C "{3}" Link -w -o "{2}" -t MPST -c 'MPS ' "{3}.o" {CLibs} Delete "{3}.o" cc -o test test.c test ---------- MPW C Results ------------ Enter Number of Iterations 150000 Broke out of Loop after: 51.00 seconds Number of Iterations: 57054 Enter Number of Iterations 150000 Broke out of Loop after: 51.00 seconds Number of Iterations: 57224 Enter Number of Iterations 150000 Broke out of Loop after: 51.00 seconds Number of Iterations: 56755 Enter Number of Iterations 150000 Broke out of Loop after: 51.00 seconds Number of Iterations: 57605 ---------- Think C Results within Think C ------------ Enter Number of Iterations 150000 loop used 44.00 seconds Loop Size 150000 Enter Number of Iterations 150000 loop used 45.00 seconds Loop Size 150000 Enter Number of Iterations 150000 loop used 45.00 seconds Loop Size 150000 Enter Number of Iterations 150000 loop used 44.00 seconds Loop Size 150000 -----------Think C Results Run From Finder -------------- Enter Number of Iterations 150000 loop used 45.00 seconds Loop Size 150000 Enter Number of Iterations 150000 loop used 44.00 seconds Loop Size 150000 .... etc --- C Code --- #include <time.h> #include <stdio.h> #define MAXTIME 50 void main(void) { time_t start,end; long int flag,n; double time_out; long t; flag = 0; printf(" Enter Number of Iterations "); scanf("%ld",&n); start = time(NULL); for(t=0; t < n; t++) { if (flag) break; end = time(NULL); time_out = difftime(end,start); if (time_out > (double) MAXTIME) { flag =1; printf("Broke out of Loop after: %6.2f seconds\n",time_out); printf("Number of Iterations: %ld \n",t); } } end = time(NULL); time_out = difftime(end,start); if (!flag) { printf("loop used %6.2f seconds\n",time_out); printf("Loop Size %ld\n",n); } }
steve@huxley.huxley.bitstream.com (Steve Stein) (03/26/91)
In article <91082.152427ACPS5788@Ryerson.Ca> ACPS5788@Ryerson.Ca (Roger Smith) writes: > including was run under both systems and the timings noted. The results > seem to indicate that Think C runs faster am I doing something wrong? > Why is there such a large Difference in the Loop Times? This is a great puzzle. The THINK C code is running about 3 times faster than the MPW code. Though I would expect THINK C to generate better code than MPW for the loop, I doubt it would be a factor of three better! My guess is that MPW is calling SANE to do the double compare in: > if (time_out > (double) MAXTIME) { whereas THINK C is using the 68881 instruction. Do you have a 68881 on the machine you're using to gen the tests? How do you have your compile options for THINK C set? How about for MPW? My second guess is that the "time" and "difftime" functions are executing faster in THINK C than in MPW. THINK C gives the source for these functions. Does MPW? Can you compare them? - Steve Stein
siegel@world.std.com (Rich Siegel) (03/27/91)
In article <STEVE.91Mar26092505@huxley.huxley.bitstream.com> <steve@bitstream.com> (Stephen Z. Stein) writes: >This is a great puzzle. The THINK C code is running about 3 times faster >than the MPW code. Though I would expect THINK C to generate better >code than MPW for the loop, I doubt it would be a factor of three better! THINK C has better floating-point code generation, which is mostly due to the fact that in THINK C, 'double' is the SANE 'Extended' data type. Since there's no internal conversion going on, floating-point calculations and comparisons are much more efficient. MPW C's 'double' is the SANE 'double'. A long time ago, I did some timings, and discovered that using 80-bit reals was as much as four times faster as using 64-bit reals. R. -- ----------------------------------------------------------------------- Rich Siegel Internet: siegel@world.std.com Software Engineer Applelink: SIEGEL Symantec Languages Group
jess@gn.ecn.purdue.edu (Jess M Holle) (03/27/91)
In article <1991Mar26.224716.29004@world.std.com> siegel@world.std.com (Rich Siegel) writes: > THINK C has better floating-point code generation, which is mostly >due to the fact that in THINK C, 'double' is the SANE 'Extended' data type. >Since there's no internal conversion going on, floating-point calculations >and comparisons are much more efficient. MPW C's 'double' is the SANE >'double'. A long time ago, I did some timings, and discovered that using >80-bit reals was as much as four times faster as using 64-bit reals. > >-- >----------------------------------------------------------------------- >Rich Siegel Internet: siegel@world.std.com >Software Engineer Applelink: SIEGEL >Symantec Languages Group Does it make any difference under MPW if the variables are declared as type extended rather than type double, or are both equally slow (ie. both translating to SANE's type double)? Jess Holle