refuge
By: a guest | Feb 20th, 2010 | Syntax:
C++ | Size: 0.87 KB | Hits: 84 | Expires: Never
#include<stdio.h>
#include<time.h>
const int XDIM = 0xF00;
const int YDIM = 0xF00;
void xy()
{
char** buff = new char* [XDIM];
for(int i=0; i<XDIM;i++)
*(buff+i) = new char[YDIM];
int x, y;
clock_t oldclock, newclock;
oldclock = clock();
for(x = 0; x < XDIM; x++)
for(y = 0; y < YDIM; y++)
buff[x][y] = '\0';
newclock = clock();
printf("x->y: %0.4f\n",(float) (newclock - oldclock) / (float) CLOCKS_PER_SEC);
return;
}
void yx()
{
char** buff = new char* [XDIM];
for(int i=0; i<XDIM;i++)
*(buff+i) = new char[YDIM];
int x, y;
clock_t oldclock, newclock;
oldclock = clock();
for(y = 0; y < YDIM; y++)
for(x = 0; x < XDIM; x++)
buff[x][y] = '\0';
newclock = clock();
printf("y->x: %0.4f\n", (float)(newclock - oldclock) / (float) CLOCKS_PER_SEC);
return;
}
main()
{
xy();
yx();
}