Subject: Performance
To: Port-Mac <port-mac68k@NetBSD.ORG>
From: None <M.Hitter@trier.fh-rpl.de>
List: port-mac68k
Date: 06/02/1996 19:32:38
As the result of a little discussion with Scott Reynolds about
performance wins/losses by the use of different variable types I
compiled a little test program (see the source at the end). The results
on my LCII (68030/16MHz) look surprising to me:
--- copyvalue.result -----------------------------------
Start simple copy:
long: 13 seconds
int: 27 seconds
short: 40 seconds
char: 53 seconds
Start subroutine calls:
long: 62 seconds
int: 67 seconds
short: 72 seconds
char: 78 seconds
--------------------------------------------------------
I don't know why simple copying the value from one variable to another
takes such different times. If I look at the MC68000 timing tables, a
MOVE instruction takes always fewer cycles for a word than for a long.
Also I'm surprised by the big differences between int and short. I
always thought 'int' and 'long' are the same on a 32-bit OS like MacBSD
or MacOS.
If we trust these tests, we should move from int to long as the
"standard" variable type!
Made I a mistake or what is the explanation for this?
Markus
-----------------------------------------------------------------------
Markus Hitter Voice: ++49/651/828172
Email: hitterm@trier.fh-rpl.de
Trier (Germany) WWW: http://www.trier.fh-rpl.de/~hitterm
--- copyvalue.c ----------------------------------------
/* compiled with 'cc -O -o copyvalue copyvalue.c'
(like the default for the kernel). */
#include <stdio.h>
#include <time.h>
void calllong (long, long);
void callint (int, int);
void callshort (short, short);
void callchar (char, char);
main()
{
long i;
time_t start;
long lfrom, lto;
int ifrom, ito;
short sfrom, sto;
char cfrom, cto;
printf ("Start simple copy: \n");
start = time (NULL);
for (i=0; i<20000000; i++) {
lto = lfrom;
}
printf ("long: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<20000000; i++) {
ito = ifrom;
}
printf ("int: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<20000000; i++) {
sto = sfrom;
}
printf ("short: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<20000000; i++) {
cto = cfrom;
}
printf ("char: %G seconds\n", difftime (time (NULL), start));
printf ("Start subroutine calls: \n");
for (i=0; i<1000000; i++) {
calllong (lfrom, lto);
}
printf ("long: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<1000000; i++) {
callint (ifrom, ito);
}
printf ("int: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<1000000; i++) {
callshort (sfrom, sto);
}
printf ("short: %G seconds\n", difftime (time (NULL), start));
for (i=0; i<1000000; i++) {
callchar (cfrom, cto);
}
printf ("char: %G seconds\n", difftime (time (NULL), start));
return 0;
}
void calllong (long a, long b) {}
void callint (int a, int b) {}
void callshort (short a, short b) {}
void callchar (char a, char b) {}
--------------------------------------------------------