📄 bnch_rct.c
字号:
/*........................... BENCH_RECT.C ................ 9-8-95 .........*/
#include <malloc.h>
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <vsa.h>
#include <vsa_font.h>
extern unsigned _stklen = 10000; /* This is for Borland C Only ! */
void main()
{
clock_t clk,delta;
unsigned x[1024],y[1024];
unsigned i,num_rects;
float timer;
unsigned char huge *image;
long sum,area;
vsa_init(0x105);
LOOP:
num_rects = 100;
srand(1);
for(i=0;i<num_rects;i++)
{
x[i] = ((unsigned long)(XResolution-1)*rand())/RAND_MAX;
y[i] = ((unsigned long)(YResolution-1)*rand())/RAND_MAX;
}
vsa_set_color(6);
vsa_move_to(0,0);
clk = clock();
for(i=0;i<num_rects;i++)
{
vsa_rect_fill(x[i],y[i]);
vsa_move_to(x[i],y[i]);
vsa_set_color(6*i);
}
delta = clock() - clk;
timer = ((float)(delta))/((float)CLOCKS_PER_SEC);
if(timer == 0) timer = .000001;
printf("elapsed drawing time = %f sec\n",timer);
sum = x[0]*y[0];
for(i=1;i<num_rects;i++)
{
area = ((long)((int)x[i] - (int)x[i-1]))*
((long)((int)y[i] - (int)y[i-1]));
if(area < 0) area = -area;
sum += area;
}
printf("RANDOM RECTANGLES: Drawing Rate = %f pixels/sec\n",sum/timer);
vsa_set_color(255);
vsa_move_to(320-1,240-1);
vsa_rect(639+1,479+1);
if(getch() == 27)
goto BAIL;
num_rects = 27;
image = (unsigned char huge *) halloc(vsa_image_size(320,240,639,479),1);
if(image == NULL)
{
printf("Not enough memory for allocation");
goto BAIL;
}
vsa_get_image(320,240,639,479,image);
vsa_set_color(0);
clk = clock();
for(i=0;i<num_rects;i++)
{
vsa_put_image(20*i,20*i,image,0);
vsa_move_to(20*i,20*i);
vsa_rect(20*i+320,20*i+240);
}
delta = clock() - clk;
timer = ((float)(delta))/((float)CLOCKS_PER_SEC);
if(timer == 0) timer = .000001;
printf("elapsed drawing time = %f sec\n",timer);
printf("BITBLT: Drawing Rate = %f pixels/sec\n",
((unsigned long)num_rects*320L*240L)/timer);
hfree(image);
if(getch() == 27)
goto BAIL;
goto LOOP;
BAIL:
vsa_init(0x3);
return;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -