home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
DP Tool Club 19
/
CD_ASCQ_19_010295.iso
/
vrac
/
pmw100.zip
/
EXAMPLE2.C
< prev
next >
Wrap
C/C++ Source or Header
|
1994-11-21
|
2KB
|
75 lines
/*****************************************************************************
The original purpose of this test program was to show that floating point
calculations do in fact work under PMODE/W. However, during development we
found that floating point under DOS/4GW was EXTREMELY slow. Run this on a
PC without an FPU or disable the FPU on your 486. Try it under DOS/4GW and
under PMODE/W and notice the speed difference. If the timing values are too
close to be able to tell, try changing the variable "count" to something
larger.
*****************************************************************************/
#include <conio.h>
#include <math.h>
#include <time.h>
#include <dos.h>
unsigned int count=10000;
#define M_PI 3.141592654
double dtemp;
int x,line;
clock_t tstart,tend;
union REGS r;
#pragma aux mode3="mov ax,3","int 10h",modify [ax];
main(void)
{
mode3();
printf("This program will test several Watcom C floating point functions\n");
printf("for speed. Each function will be executed %d times. Depending\n",count);
printf("on the speed of your system, this may take a while. This test is\n");
printf("only of use on systems WITHOUT a floating point unit.\n");
line=6;
gotoxy(0,line);
tstart=clock();
cprintf("pow() Test");
for(x=0;x<count;x++) {gotoxy(30,line); dtemp=pow(1234,56); cprintf("%-6u",x);}
tend=clock();
gotoxy(40,line);
cprintf("%.4f Seconds\r\n",(float)(tend-tstart)/(float)CLOCKS_PER_SEC);
line++;
tstart=clock();
cprintf("sin() Test");
for(x=0;x<count;x++) {gotoxy(30,line); dtemp=sin(123456789); cprintf("%-6u",x);}
tend=clock();
gotoxy(40,line);
cprintf("%.4f Seconds\r\n",(float)(tend-tstart)/(float)CLOCKS_PER_SEC);
line++;
tstart=clock();
cprintf("sqrt() Test");
for(x=0;x<count;x++) {gotoxy(30,line); dtemp=sqrt(123456789); cprintf("%-6u",x);}
tend=clock();
gotoxy(40,line);
cprintf("%.4f Seconds\r\n",(float)(tend-tstart)/(float)CLOCKS_PER_SEC);
exit(0);
}
void gotoxy(unsigned char gx,unsigned char gy){
r.h.ah=2;
r.h.bh=0;
r.h.dl=gx;
r.h.dh=gy;
int386(0x10,&r,&r);
return;
}