Skip to content

Commit

Permalink
A simple mechanism for measuring optimizations.
Browse files Browse the repository at this point in the history
  • Loading branch information
BSVino committed Dec 12, 2014
1 parent 1588dd5 commit 596bb2e
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions game/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,49 @@ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON A

#include "game.h"

#ifdef _WIN32
#include "sys/timeb.h"
#endif

int main(int argc, char* argv[])
{
struct timeb t1, t2;

ftime(&t1);

long sum;
for (int n = 0; n < 1000000000; n++)
{
sum = 0;
for (int i = 0; i < 1000; i++)
sum += i;
}

ftime(&t2);

long elapsed_ms = (long)(t2.time - t1.time) * 1000 + (t2.millitm - t1.millitm);

printf("Result: %d\n", sum);
printf("Elapsed: %dms\n", elapsed_ms);






return 0;












// Create a game
CGame game(argc, argv);

Expand Down

0 comments on commit 596bb2e

Please sign in to comment.