/*
 * Copyright (c) 2001
 * Hansjörg Malthaner
 *
 * Permission to use, copy, modify and distribute this software
 * for any purpose is hereby granted without fee, provided that 
 * the above copyright notice appear in all copies and that both
 * that copyright notice and this permission notice appear in 
 * supporting documentation.  
 *
 * I make no representations about the suitability of this software
 * for any purpose.  
 * It is provided "as is" without express or implied warranty.
 */

#include <time.h>

#define LOOPS 1000

int main() {
  const int width = 640;
  const int height = 400;

  int arr[width*height];

  clock_t t0, t1, te;
  int i,x,y;

  t0 = clock();

  i=0;
  do {
    i++;
  } while(i<LOOPS);


  t1 = clock();

  te = t1-t0;

  printf("Empty test loop took %f seconds\n", ((double)te)/CLOCKS_PER_SEC);



  t0 = clock();

  i=0;
  do {

    for(y=0; y<height; y++) {
      for(x=0; x<width; x++) {
        arr[y*width+x] = x;
      }
    }

    i++;
  } while(i<LOOPS);


  t1 = clock();

  printf("Loop 1 took %f seconds\n", ((double)(t1-t0)-te)/CLOCKS_PER_SEC);


  t0 = clock();

  i=0;
  do {

    for(y=0; y<height; y++) {
      const int line = y*width;
      for(x=0; x<width; x++) {
        arr[line+x] = x;
      }
    }

    i++;
  } while(i<LOOPS);


  t1 = clock();

  printf("Loop 2 took %f seconds\n", ((double)(t1-t0)-te)/CLOCKS_PER_SEC);

}
