Thread View: comp.sys.acorn.tech
2 messages
2 total messages
Started by Andrew P.Mell
Tue, 28 Jul 1992 02:48
C Time Trials/Comparison
Author: Andrew P.Mell
Date: Tue, 28 Jul 1992 02:48
Date: Tue, 28 Jul 1992 02:48
139 lines
8403 bytes
8403 bytes
I've been testing the C performance of an Acorn R260 against a
Sparcstation IPC, heres the results. They make interesting reading as
they show the vagaries of the ARM instruction set. note how fast the
integer multiply is compared to the integer divide. Why is the float
multiply faster than add/subtract? Theres a few other interesting
oddities, but I leave them to you to compare. Float performance is bad
on the ARM as expected because the Sparc has an FPA.
(Look at the far right column to compare, clock tick (HZ) is different on
each machine so clicks/trial is less relevant, ARM=100Hz Sparc=60Hz)
uS/loop is the most relevant statistic, the ARM beats the Sparc in
some areas. Note Normal SunOS cc was used with the Optimize flag, this
made the code a great deal faster where Optimize on the ARM did little.
If you want a copy of the code, mail me - andy@santafe.edu
Andy
Acorn R260 (running RisciX 1.2)
Operation Clicks for each trial Mics/N
Null Loop (n=1000000)
{} 17 17 17 17 17 0.17
Int Operations (n=1000000)
i1++ 68 67 68 70 69 0.51
i1 = i2 67 68 67 67 68 0.50
i1 = i2 + i3 68 67 67 68 67 0.50
i1 = i2 - i3 67 68 67 68 67 0.50
i1 = i2 * i3 68 67 67 68 67 0.50
i1 = i2 / i3 163 162 162 162 163 1.45
i1 = i2 % i3 187 186 187 188 186 1.70
Float Operations (n=1000000)
f1 = f2 598 598 599 598 599 5.81
f1 = f2 + f3 868 869 1147 868 868 9.07
f1 = f2 - f3 868 869 854 867 869 8.48
f1 = f2 * f3 684 684 683 684 685 6.67
f1 = f2 / f3 3477 3753 3478 3477 3477 35.15
Numeric Conversions (n=1000000)
i1 = f1 52 53 53 52 53 0.36
f1 = i1 684 684 684 685 683 6.67
Integer Vector Operations (n=1000000)
v[i] = i 67 67 68 67 67 0.50
v[v[i]] = i 101 102 101 101 102 0.84
v[v[v[i]]] = i 118 117 118 117 118 1.01
Control Structures (n=1000000)
if (i == 5) i1++ 31 30 31 30 31 0.14
if (i != 5) i1++ 68 68 67 68 68 0.51
while (i < 0) i1++ 24 23 24 24 24 0.07
i1 = sum1(i2) 88 87 87 87 87 0.70
i1 = sum2(i2, i3) 102 101 101 101 101 0.84
i1 = sum3(i2, i3, i4) 111 112 111 112 111 0.94
Input/Output (n=10000)
fputs(s, fp) 18 18 18 18 18 17.83
fgets(s, 9, fp) 18 18 17 17 18 17.43
fprintf(fp, sdn, i) 62 62 62 62 62 61.83
fscanf(fp, sd, &i1) 95 96 97 96 93 95.23
Malloc (n=10000)
free(malloc(8)) 4 5 5 5 4 4.43
push(i) 7 7 7 7 7 6.83
i1 = pop() 2 2 2 3 2 2.03?
String Functions (n=100000)
strcpy(s, s0123456789) 40 48 40 40 40 3.99
i1 = strcmp(s, s) 37 38 37 37 38 3.57
i1 = strcmp(s, sa123456789) 18 18 18 18 18 1.63
String/Number Conversions (n=10000)
i1 = atoi(s12345) 23 23 22 21 21 21.83
sscanf(s12345, sd, &i1) 85 86 86 85 86 85.43
sprintf(s, sd, i) 63 63 62 63 63 62.63
f1 = atof(s123_45) 137 138 138 138 138 137.63
sscanf(s123_45, sf, &f1) 385 385 386 386 386 385.43
sprintf(s, sf62, 123.45) 397 397 398 397 397 397.03
Math Functions (n=10000)
i1 = rand() 6 5 5 6 5 5.23
f1 = log(f2) 179 178 180 179 179 178.83
f1 = exp(f2) 189 187 187 185 187 186.83
f1 = sin(f2) 231 230 232 231 231 230.83
f1 = sqrt(f2) 78 79 78 79 78 78.23
Sun Sparcstation IPC (running SunOS 4.1.2)
standard SunOS cc with -O flag
Operation Clicks for each trial Mics/N
Null Loop (n=1000000)
{} 7 7 8 7 7 0.12
Int Operations (n=1000000)
i1++ 22 22 23 19 22 0.24
i1 = i2 21 24 22 22 22 0.25
i1 = i2 + i3 20 19 20 20 20 0.21
i1 = i2 - i3 19 20 19 20 19 0.20
i1 = i2 * i3 19 20 20 20 19 0.21
i1 = i2 / i3 20 20 20 19 20 0.21
i1 = i2 % i3 19 20 20 20 19 0.21
Float Operations (n=1000000)
f1 = f2 20 19 20 20 20 0.21
f1 = f2 + f3 20 19 20 19 25 0.22
f1 = f2 - f3 20 26 28 23 23 0.28
f1 = f2 * f3 26 24 19 20 22 0.25
f1 = f2 / f3 20 19 20 21 21 0.22
Numeric Conversions (n=1000000)
i1 = f1 32 32 33 31 32 0.41
f1 = i1 43 43 44 45 44 0.61
Integer Vector Operations (n=1000000)
v[i] = i 22 23 24 24 22 0.26
v[v[i]] = i 33 33 35 33 33 0.44
v[v[v[i]]] = i 41 41 41 41 41 0.56
Control Structures (n=1000000)
if (i == 5) i1++ 12 12 12 13 12 0.08
if (i != 5) i1++ 33 35 33 34 34 0.44
while (i < 0) i1++ 12 12 12 13 12 0.08
i1 = sum1(i2) 27 26 27 26 27 0.32
i1 = sum2(i2, i3) 29 30 28 30 29 0.37
i1 = sum3(i2, i3, i4) 36 36 37 36 41 0.50
Input/Output (n=10000)
fputs(s, fp) 6 6 7 8 8 11.55
fgets(s, 9, fp) 5 4 5 4 5 7.55
fprintf(fp, sdn, i) 28 28 27 27 26 45.21
fscanf(fp, sd, &i1) 37 36 39 36 36 61.21
Malloc (n=10000)
free(malloc(8)) 12 12 12 12 11 19.55
push(i) 6 6 6 6 7 10.21
i1 = pop() 0 2 1 1 1 1.55?
String Functions (n=100000)
strcpy(s, s0123456789) 21 21 22 23 22 3.51
i1 = strcmp(s, s) 25 26 25 25 25 4.08
i1 = strcmp(s, sa123456789) 15 15 14 14 15 2.31
String/Number Conversions (n=10000)
i1 = atoi(s12345) 3 3 3 3 3 4.88
sscanf(s12345, sd, &i1) 39 39 39 39 40 65.21
sprintf(s, sd, i) 26 26 27 27 26 43.88
f1 = atof(s123_45) 232 231 232 231 233 386.21
sscanf(s123_45, sf, &f1) 212 212 213 212 212 353.55
sprintf(s, sf62, 123.45) 222 223 223 224 222 371.21
Math Functions (n=10000)
i1 = rand() 3 2 3 3 2 4.21
f1 = log(f2) 5 6 5 6 5 8.88
f1 = exp(f2) 7 6 7 6 7 10.88
f1 = sin(f2) 8 8 9 7 9 13.55
f1 = sqrt(f2) 11 11 11 12 11 18.55
Re: C Time Trials/Comparison
Author: TMOTA
Date: Wed, 29 Jul 1992 07:24
Date: Wed, 29 Jul 1992 07:24
12 lines
1023 bytes
1023 bytes
amell@nyx.cs.du.edu (Andrew P.Mell) writes: >integer multiply is compared to the integer divide. Why is the float >multiply faster than add/subtract? Because to multiply floats, you multiply the mantissas, and ADD the exponents, while to +/-, you have to normalise first... The normalisation process is a lot slower than the whole multiply process... -- _________________ "I'd like to answer this question in two ways: /____ _ _/_ __ First in my normal voice, and then // / //_//_ /_/ in a silly, high-pitched whine." (Monty Python)
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads