- add compile option to change innermost loop into a function call

to measure function call overhead.
- always call dump fn so I can do regression test
This commit is contained in:
Bryce Denney 2002-04-16 16:08:18 +00:00
parent 8d53729ed3
commit b6c94bebdb

View File

@ -1,6 +1,6 @@
/*
*
* $Id: blur.c,v 1.2 2002-04-16 14:30:47 bdenney Exp $
* $Id: blur.c,v 1.3 2002-04-16 16:08:18 bdenney Exp $
*
*/
@ -17,6 +17,13 @@ int array2[MAX][MAX];
#define DEFAULT_TIMES 1000
#ifdef BLUR_USE_FUNCTION_CALL
void blur_func (int *sum, int *data)
{
*sum += *data;
}
#endif
void blur()
{
int sum;
@ -26,8 +33,13 @@ void blur()
{
sum = 0;
for (x2=x-BLUR_WINDOW_HALF; x2<=x+BLUR_WINDOW_HALF; x2++)
for (y2=y-BLUR_WINDOW_HALF; y2<=y+BLUR_WINDOW_HALF; y2++)
for (y2=y-BLUR_WINDOW_HALF; y2<=y+BLUR_WINDOW_HALF; y2++) {
#ifdef BLUR_USE_FUNCTION_CALL
blur_func (&sum, &array[x2][y2]);
#else
sum += array[x2][y2];
#endif
}
array2[x][y] = sum;
}
}
@ -71,6 +83,7 @@ int main (int argc, char *argv[])
{
int i;
int times = 0;
FILE *out;
if (argc>1) {
assert (sscanf (argv[1], "%d", &times) == 1);
} else {
@ -84,6 +97,9 @@ int main (int argc, char *argv[])
stop_timer();
report_time (stdout, times);
//fprintf (stderr, "-----------------------------------\n");
//dump_array (stderr);
out = fopen ("blur.out", "w");
assert (out != NULL);
dump_array (out);
fclose (out);
return 0;
}