Path: utzoo!utgpu!utorvm!ryerson!acps5788 Organization: Ryerson - Academic Computing Services Date: Saturday, 23 Mar 1991 15:24:27 EST From: Roger Smith Message-ID: <91082.152427ACPS5788@Ryerson.Ca> Newsgroups: comp.sys.mac.programmer Subject: Think C vs MPW C?? 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 #include #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); } }