home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Format CD 28
/
amigaformatcd28.iso
/
-seriously_amiga-
/
misc
/
posbb
/
src
/
generic
/
io.c
next >
Wrap
C/C++ Source or Header
|
1998-05-09
|
4KB
|
177 lines
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
/* #include "posbb_tests.h" // this would be needed by Test_qsort,not finished,yet
*/
#define TRUE -1
#define FALSE 0
/****** posbb_tests.c/Test_printf ******************************************
*
* NAME
* Test_printf -- Tests the speed of the ANSI function printf().
*
* SYNOPSIS
* time = Test_printf( void )
* int Test_printf( void );
*
* FUNCTION
* Writes 1,000 times the string "printf test in progress...\n" to stdout
* and returns the time taken.
*
* RESULT
* time - number of seconds taken. No error possible.
*
* EXAMPLE
* See posbb.c/Perform_Tests().
*
* BUGS
* It hasn't bugs,but since it can't turn off multitasking,the result
* could change if the user runs some program or move windows.
*
****************************************************************************
*/
int Test_printf( precision )
int precision;
{
int c;
time_t time1,time2;
time1 = time(NULL);
for ( c = 0; c<1000*precision; c++ )
{
printf("printf test in progress...\n");
}
time2 = time(NULL);
return (time2-time1);
}
/****** posbb_tests.c/Test_Write ********************************************
*
* NAME
* Test_Write -- Tests disk writing speed.
*
* SYNOPSIS
* time = Test_Write( void )
* int Test_Write( void );
*
* FUNCTION
* Writes a block of data to a file,with dos.library/Write() (in the Amiga
* version).
*
* INPUT
* Now void,in future versions a STRPTR,the name of the file to write to.
*
* RESULT
* time - Number of seconds taken.
* Returns TRUE if something went wrong ( memory or disk space usually).
* In future may return differents error codes.
*
* EXAMPLE
* See posbb.c/Perform_Tests.
*
* BUGS
* No known bugs.
*
****************************************************************************
*/
/*
int Test_Write( void )
{
int clk;
int c;
long buf;
BPTR file;
if ( buf=AllocMem(262144,NULL))
{
Forbid();
( int ) time1 = time(NULL);
if (( BPTR ) file = Open("RAM:POSBB_TestFile",( ULONG ) MODE_NEWFILE))
{
Write(file,buf,262144);
Close(file);
( int ) time1 = time(NULL);
Permit();
FreeMem(buf,262144);
}
}
if (file = NULL) return TRUE;
else return (clk);
}
*/
/****** posbb_tests.c/Test_Read ********************************************
*
* This section of the autodoc isn't finished. See Test_Write().
* The function doesn't works in the generic version,yet.
*
*******
*/
/* This is the Amiga one
int Test_Read( void )
{
int clk;
long buf;
BPTR file = NULL;
if ( buf = AllocMem((262144),0))
{
Forbid();
( int ) time1 = time(NULL);
if ( ( BPTR ) file = Open("RAM:POSBB_TestFile",MODE_OLDFILE) )
{
Read(file,buf,262144);
( int ) l2= clock();
Permit();
Close(file);
}
FreeMem(buf,262144);
}
if (file = NULL) return TRUE;
else return (clk);
}
*/
/****** posbb_tests.c/Test_WritePixel **************************************
*
* This function doesn't work.In the generic version.
*
********
*/
/*
int strsrt(s1,s2) // this function is needed by Test_qsort,but I'll change them
char *s1,*s2;
{
return (s1[1]-s2[1]);
}
int Test_qsort(precision) // This test isn't finished,yet. It doesn't work but I should change it.
int precision;
{
int c;
time_t time1,time2;
time1 = time(NULL);
qsort(StrList,15,sizeof(char *),strsrt);
time2 = time(NULL);
for (c = 0;c<15;c++)
{
printf("%d %s\n",c,StrList[c]);
}
return (time2-time1);
}
*/