#include <stdio.h>
#include <time.h>


static int	FunctionD( int x)
{
if ( x==0)	return 4;
return 3;
}

static int	FunctionA( int x)
{
int	i;
for ( i=0; i<20; i++)	{
	x += 1;
	FunctionD( x);
	}
return x;
}


static int	FunctionB( int x)
{
int	i;
for ( i=0; i<1000; i++)	x += 1;
return x;
}

static void	NullFunction()
{
}


#define ITS 1000

static void FunctionC( void)
{
int	i, ii;
clock_t	t, t_a, t_b, t_null;

t = clock();
for ( i=0; i<ITS; i++)	NullFunction();
t_null = clock() - t;

t = clock();
for ( i=0; i<ITS; i++)	ii = FunctionA(0);
t_a = clock() - t;

t = clock();
for ( i=0; i<ITS; i++)	ii = FunctionB(0);
t_b = clock() - t;

printf( "Function name          Time for %i iterations (s)\n", ITS);
printf( "---------------------------------------------\n");
printf( "NullFunction                   %g\n", (double) t_null / CLOCKS_PER_SEC);
printf( "FunctionA                      %g\n", (double) t_a    / CLOCKS_PER_SEC);
printf( "FunctionB                      %g\n", (double) t_b    / CLOCKS_PER_SEC);

/*
printf( "\n");
printf( "FunctionA-NullFunction         %g\n", ((double) t_a-t_null) / CLOCKS_PER_SEC);
printf( "FunctionB-NullFunction         %g\n", ((double) t_b-t_null) / CLOCKS_PER_SEC);
*/
printf( "\n\n");

}



int main( void)
{

printf( "HierProf test program started\n\n");

FunctionC();


printf( "Finished\n");


printf	(
	"\n\n"
	"The profile output contains rather long lines, and line-wrapping\n"
	"destroys the appearence of the output, so set your text-editor's\n"
	"line-width to a large value to view the profile data.\n"
	);

/* Profile data will be automatically be written to stderr when this program exits.	*/

return 0;
}

