Guest
Public paste!

refuge

By: a guest | Feb 20th, 2010 | Syntax: C++ | Size: 0.87 KB | Hits: 84 | Expires: Never
Copy text to clipboard
  1. #include<stdio.h>
  2. #include<time.h>
  3. const int XDIM = 0xF00;
  4. const int YDIM = 0xF00;
  5. void xy()
  6. {
  7.   char** buff = new char* [XDIM];
  8.   for(int i=0; i<XDIM;i++)
  9.      *(buff+i) = new char[YDIM];
  10.   int x, y;
  11.   clock_t oldclock, newclock;
  12.   oldclock = clock();
  13.   for(x = 0; x < XDIM; x++)
  14.     for(y = 0; y < YDIM; y++)
  15.       buff[x][y] = '\0';
  16.   newclock = clock();
  17.   printf("x->y: %0.4f\n",(float) (newclock - oldclock) / (float) CLOCKS_PER_SEC);
  18.   return;
  19. }
  20. void yx()
  21. {
  22.   char** buff = new char* [XDIM];
  23.   for(int i=0; i<XDIM;i++)
  24.      *(buff+i) = new char[YDIM];
  25.   int x, y;
  26.   clock_t oldclock, newclock;
  27.   oldclock = clock();
  28.   for(y = 0; y < YDIM; y++)
  29.     for(x = 0; x < XDIM; x++)
  30.       buff[x][y] = '\0';
  31.   newclock = clock();
  32.   printf("y->x: %0.4f\n", (float)(newclock - oldclock) / (float) CLOCKS_PER_SEC);
  33.   return;
  34. }
  35. main()
  36. {
  37.      xy();
  38.      yx();
  39. }