#include #include #include #define TESTCOUNT 100 #define WIDTH 128 #define HEIGHT 128 void main(void) { DWORD timesrc, timedst; int i, x, y, test; BYTE *src1, *src2, *dst; BYTE *src1v[HEIGHT], *src2v[HEIGHT], *dstv[HEIGHT]; src1 = new BYTE[WIDTH*HEIGHT]; src2 = new BYTE[WIDTH*HEIGHT]; dst = new BYTE[WIDTH*HEIGHT]; for(i = 0; i < HEIGHT; i ++) { src1v[i] = src1 +i*WIDTH; src2v[i] = src2 +i*WIDTH; dstv[i] = dst +i*WIDTH; } srand(timeGetTime( )); // 元イメージ作成 for(i = 0; i < WIDTH*HEIGHT; i ++) { src1[i] = rand( ) & 0xff; src2[i] = rand( ) & 0xff; } //---------------------------------------- // 縦スキャン型 for(test = 0; test < TESTCOUNT; test ++) for(x = 0; x < WIDTH; x ++) for(y = 0; y < HEIGHT; y ++) dstv[y][x] = (src1v[y][x] == 0) ? src2v[y][x] : src1v[y][x]; // 開始 timesrc = timeGetTime( ); for(test = 0; test < TESTCOUNT; test ++) for(x = 0; x < WIDTH; x ++) for(y = 0; y < HEIGHT; y ++) dstv[y][x] = (src1v[y][x] == 0) ? src2v[y][x] : src1v[y][x]; timedst = timeGetTime( ); printf("vertical: %ld\n", timedst - timesrc); //---------------------------------------- // 横スキャン型 for(test = 0; test < TESTCOUNT; test ++) for(y = 0; y < HEIGHT; y ++) for(x = 0; x < WIDTH; x ++) dstv[y][x] = (src1v[y][x] == 0) ? src2v[y][x] : src1v[y][x]; // 開始 timesrc = timeGetTime( ); for(test = 0; test < TESTCOUNT; test ++) for(y = 0; y < HEIGHT; y ++) for(x = 0; x < WIDTH; x ++) dstv[y][x] = (src1v[y][x] == 0) ? src2v[y][x] : src1v[y][x]; timedst = timeGetTime( ); printf("horizone: %ld\n", timedst - timesrc); }