#include <bios.h>
#include <stdio.h>
#define SIZE_FIELD 10
struct s_test
{
int filler;
char field[SIZE_FIELD];
};
struct s_test test_structure = {1, "TESTFIELD"};
struct s_test *structure_pointer = &test_structure;
char *char_pointer = test_structure.field;
#define REPEAT_LIMIT 100000L
time_function(p_function)
int (*p_function)();
{
long start_time, stop_time;
long l;
_bios_timeofday(_TIME_GETCLOCK, &start_time);
for (l=0; l < REPEAT_LIMIT; l++)
{
(*p_function)();
}
_bios_timeofday(_TIME_GETCLOCK, &stop_time);
printf("\n Elapsed time %ld start %ld stop %ld repetitions %ld",
stop_time - start_time, start_time, stop_time, REPEAT_LIMIT);
}
dummy_function(pointer)
void *pointer;
{
return;
}
access_with_char_pointer()
{
char *cp;
cp = char_pointer;
dummy_function(cp);
}
access_with_structure_pointer()
{
char *cp;
cp = structure_pointer->field;
dummy_function(cp);
}
main()
{
printf("\n Dummy function");
time_function(dummy_function);
printf("\n access_with_char_pointer");
time_function(access_with_char_pointer);
printf("\n access_with_structure_pointer");
time_function(access_with_structure_pointer);
}
/* End of File */