home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / sys / acorn / tech / 3 < prev    next >
Encoding:
Text File  |  1992-07-27  |  8.1 KB  |  151 lines

  1. Newsgroups: comp.sys.acorn.tech
  2. Path: sparky!uunet!mnemosyne.cs.du.edu!nyx!amell
  3. From: amell@nyx.cs.du.edu (Andrew P.Mell)
  4. Subject: C Time Trials/Comparison
  5. Message-ID: <1992Jul28.024814.1386@mnemosyne.cs.du.edu>
  6. Sender: usenet@mnemosyne.cs.du.edu (netnews admin account)
  7. Organization: Nyx, Public Access Unix @ U. of Denver Math/CS dept.
  8. Date: Tue, 28 Jul 92 02:48:14 GMT
  9. Lines: 140
  10.  
  11. I've been testing the C performance of an Acorn R260 against a
  12. Sparcstation IPC, heres the results. They make interesting reading as
  13. they show the vagaries of the ARM instruction set. note how fast the
  14. integer multiply is compared to the integer divide. Why is the float
  15. multiply faster than add/subtract? Theres a few other interesting
  16. oddities, but I leave them to you to compare. Float performance is bad
  17. on the ARM as expected because the Sparc has an FPA.
  18.  
  19. (Look at the far right column to compare, clock tick (HZ) is different on
  20. each machine so clicks/trial is less relevant, ARM=100Hz Sparc=60Hz)
  21.  
  22. uS/loop is the most relevant statistic, the ARM beats the Sparc in 
  23. some areas. Note Normal SunOS cc was used with the Optimize flag, this 
  24. made the code a great deal faster where Optimize on the ARM did little.
  25.  
  26. If you want a copy of the code, mail me - andy@santafe.edu
  27.  
  28. Andy
  29.  
  30. Acorn R260 (running RisciX 1.2) 
  31.  
  32.   Operation                         Clicks for each trial    Mics/N
  33. Null Loop (n=1000000)
  34.   {}                               17   17   17   17   17      0.17
  35. Int Operations (n=1000000)
  36.   i1++                             68   67   68   70   69      0.51
  37.   i1 = i2                          67   68   67   67   68      0.50
  38.   i1 = i2 + i3                     68   67   67   68   67      0.50
  39.   i1 = i2 - i3                     67   68   67   68   67      0.50
  40.   i1 = i2 * i3                     68   67   67   68   67      0.50
  41.   i1 = i2 / i3                    163  162  162  162  163      1.45
  42.   i1 = i2 % i3                    187  186  187  188  186      1.70
  43. Float Operations (n=1000000)
  44.   f1 = f2                         598  598  599  598  599      5.81
  45.   f1 = f2 + f3                    868  869 1147  868  868      9.07
  46.   f1 = f2 - f3                    868  869  854  867  869      8.48
  47.   f1 = f2 * f3                    684  684  683  684  685      6.67
  48.   f1 = f2 / f3                   3477 3753 3478 3477 3477     35.15
  49. Numeric Conversions (n=1000000)
  50.   i1 = f1                          52   53   53   52   53      0.36
  51.   f1 = i1                         684  684  684  685  683      6.67
  52. Integer Vector Operations (n=1000000)
  53.   v[i] = i                         67   67   68   67   67      0.50
  54.   v[v[i]] = i                     101  102  101  101  102      0.84
  55.   v[v[v[i]]] = i                  118  117  118  117  118      1.01
  56. Control Structures (n=1000000)
  57.   if (i == 5) i1++                 31   30   31   30   31      0.14
  58.   if (i != 5) i1++                 68   68   67   68   68      0.51
  59.   while (i < 0) i1++               24   23   24   24   24      0.07
  60.   i1 = sum1(i2)                    88   87   87   87   87      0.70
  61.   i1 = sum2(i2, i3)               102  101  101  101  101      0.84
  62.   i1 = sum3(i2, i3, i4)           111  112  111  112  111      0.94
  63. Input/Output (n=10000)
  64.   fputs(s, fp)                     18   18   18   18   18     17.83
  65.   fgets(s, 9, fp)                  18   18   17   17   18     17.43
  66.   fprintf(fp, sdn, i)              62   62   62   62   62     61.83
  67.   fscanf(fp, sd, &i1)              95   96   97   96   93     95.23
  68. Malloc (n=10000)
  69.   free(malloc(8))                   4    5    5    5    4      4.43
  70.   push(i)                           7    7    7    7    7      6.83
  71.   i1 = pop()                        2    2    2    3    2      2.03?
  72. String Functions (n=100000)
  73.   strcpy(s, s0123456789)           40   48   40   40   40      3.99
  74.   i1 = strcmp(s, s)                37   38   37   37   38      3.57
  75.   i1 = strcmp(s, sa123456789)      18   18   18   18   18      1.63
  76. String/Number Conversions (n=10000)
  77.   i1 = atoi(s12345)                23   23   22   21   21     21.83
  78.   sscanf(s12345, sd, &i1)          85   86   86   85   86     85.43
  79.   sprintf(s, sd, i)                63   63   62   63   63     62.63
  80.   f1 = atof(s123_45)              137  138  138  138  138    137.63
  81.   sscanf(s123_45, sf, &f1)        385  385  386  386  386    385.43
  82.   sprintf(s, sf62, 123.45)        397  397  398  397  397    397.03
  83. Math Functions (n=10000)
  84.   i1 = rand()                       6    5    5    6    5      5.23
  85.   f1 = log(f2)                    179  178  180  179  179    178.83
  86.   f1 = exp(f2)                    189  187  187  185  187    186.83
  87.   f1 = sin(f2)                    231  230  232  231  231    230.83
  88.   f1 = sqrt(f2)                    78   79   78   79   78     78.23
  89.  
  90. Sun Sparcstation IPC (running SunOS 4.1.2)
  91. standard SunOS cc with -O flag
  92.  
  93.   Operation                         Clicks for each trial    Mics/N
  94. Null Loop (n=1000000)
  95.   {}                                7    7    8    7    7      0.12
  96. Int Operations (n=1000000)
  97.   i1++                             22   22   23   19   22      0.24
  98.   i1 = i2                          21   24   22   22   22      0.25
  99.   i1 = i2 + i3                     20   19   20   20   20      0.21
  100.   i1 = i2 - i3                     19   20   19   20   19      0.20
  101.   i1 = i2 * i3                     19   20   20   20   19      0.21
  102.   i1 = i2 / i3                     20   20   20   19   20      0.21
  103.   i1 = i2 % i3                     19   20   20   20   19      0.21
  104. Float Operations (n=1000000)
  105.   f1 = f2                          20   19   20   20   20      0.21
  106.   f1 = f2 + f3                     20   19   20   19   25      0.22
  107.   f1 = f2 - f3                     20   26   28   23   23      0.28
  108.   f1 = f2 * f3                     26   24   19   20   22      0.25
  109.   f1 = f2 / f3                     20   19   20   21   21      0.22
  110. Numeric Conversions (n=1000000)
  111.   i1 = f1                          32   32   33   31   32      0.41
  112.   f1 = i1                          43   43   44   45   44      0.61
  113. Integer Vector Operations (n=1000000)
  114.   v[i] = i                         22   23   24   24   22      0.26
  115.   v[v[i]] = i                      33   33   35   33   33      0.44
  116.   v[v[v[i]]] = i                   41   41   41   41   41      0.56
  117. Control Structures (n=1000000)
  118.   if (i == 5) i1++                 12   12   12   13   12      0.08
  119.   if (i != 5) i1++                 33   35   33   34   34      0.44
  120.   while (i < 0) i1++               12   12   12   13   12      0.08
  121.   i1 = sum1(i2)                    27   26   27   26   27      0.32
  122.   i1 = sum2(i2, i3)                29   30   28   30   29      0.37
  123.   i1 = sum3(i2, i3, i4)            36   36   37   36   41      0.50
  124. Input/Output (n=10000)
  125.   fputs(s, fp)                      6    6    7    8    8     11.55
  126.   fgets(s, 9, fp)                   5    4    5    4    5      7.55
  127.   fprintf(fp, sdn, i)              28   28   27   27   26     45.21
  128.   fscanf(fp, sd, &i1)              37   36   39   36   36     61.21
  129. Malloc (n=10000)
  130.   free(malloc(8))                  12   12   12   12   11     19.55
  131.   push(i)                           6    6    6    6    7     10.21
  132.   i1 = pop()                        0    2    1    1    1      1.55?
  133. String Functions (n=100000)
  134.   strcpy(s, s0123456789)           21   21   22   23   22      3.51
  135.   i1 = strcmp(s, s)                25   26   25   25   25      4.08
  136.   i1 = strcmp(s, sa123456789)      15   15   14   14   15      2.31
  137. String/Number Conversions (n=10000)
  138.   i1 = atoi(s12345)                 3    3    3    3    3      4.88
  139.   sscanf(s12345, sd, &i1)          39   39   39   39   40     65.21
  140.   sprintf(s, sd, i)                26   26   27   27   26     43.88
  141.   f1 = atof(s123_45)              232  231  232  231  233    386.21
  142.   sscanf(s123_45, sf, &f1)        212  212  213  212  212    353.55
  143.   sprintf(s, sf62, 123.45)        222  223  223  224  222    371.21
  144. Math Functions (n=10000)
  145.   i1 = rand()                       3    2    3    3    2      4.21
  146.   f1 = log(f2)                      5    6    5    6    5      8.88
  147.   f1 = exp(f2)                      7    6    7    6    7     10.88
  148.   f1 = sin(f2)                      8    8    9    7    9     13.55
  149.   f1 = sqrt(f2)                    11   11   11   12   11     18.55
  150.  
  151.