I'm doing a little experiment to test the speed difference between a C app and a Java app. I'm not sure what the best way is to display true speed. Should I have the apps perform certain calcs a number of times and find the difference in seconds? Here is what I have so far. It completes in about 50 seconds on my development box.
Code:
/*
Display the speed of C.
*/
#include <stdio.h>
#include <time.h>
long startTime, endingTime, totalTime;
void showTheSpeed(int loops)
{
int i;
startTime = time(NULL);
for(i = 0; i < loops; i++)
{
printf("%d \n", i);
}
endingTime = time(NULL);
totalTime = endingTime - startTime;
printf("Completed %d loops in %d seconds. \n", loops, totalTime);
}
int main()
{
showTheSpeed(1000000);
return 0;
}