newlib/winsup/testsuite/winsup.api/iospeed.c
Christopher Faylor 9b978ffe8b * libltp/include/test.h: Fix C warnings.
* winsup.api/checksignal.c: Ditto.
* winsup.api/crlf.c: Ditto.
* winsup.api/devzero.c: Ditto.
* winsup.api/iospeed.c: Ditto.
* winsup.api/mmaptest01.c: Ditto.
* winsup.api/mmaptest02.c: Ditto.
* winsup.api/mmaptest03.c: Ditto.
* winsup.api/mmaptest04.c: Ditto.
* winsup.api/nullgetcwd.c: Ditto.
* winsup.api/sigchld.c: Ditto.
* winsup.api/signal-into-win32-api.c: Ditto.
* winsup.api/systemcall.c: Ditto.
* winsup.api/waitpid.c: Ditto.
* winsup.api/pthread/mainthreadexits.c: Ditto.
* winsup.api/pthread/test.h: Ditto.
* winsup.api/pthread/threadidafterfork.c: Ditto.
* Makefile.in: Remove cygrun.exe from RUNTIME since it is built here now.
2003-01-23 21:21:28 +00:00

116 lines
1.7 KiB
C

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <unistd.h>
#include <windows.h>
int verbose = 0;
void
v(char *fmt, ...)
{
va_list ap;
if (!verbose) return;
va_start(ap, fmt);
vfprintf(stdout, fmt, ap);
va_end(ap);
}
#define TSIZE (1024 * 1024 * 16)
unsigned long start_tic;
void
start(FILE *f)
{
fseek(f, 0, SEEK_SET);
start_tic = GetTickCount();
}
void
end()
{
unsigned long end_tic = GetTickCount();
printf("%6ld", end_tic - start_tic);
}
void
test(int linesz, int cr)
{
FILE *f = fopen("iospeed.dat", "wb");
char buf[65536];
int i, fd;
memset(buf, 'x', linesz);
buf[linesz-1] = '\n';
if (cr)
buf[linesz-2] = '\r';
for (i=0; i<TSIZE; i += linesz)
fwrite(buf, 1, linesz, f);
fclose(f);
f = fopen("iospeed.dat", "rt");
fd = fileno(f);
printf("%6d%6d", linesz, cr);
for (i=0; i<TSIZE; i+= 65536)
read(fd, buf, 65536);
start(f);
while (getc(f) != EOF);
end();
start(f);
while (fread(buf, 1, 256, f) > 0);
end();
start(f);
while (fgets(buf, 64436, f));
end();
f = fopen("iospeed.dat", "rb");
fd = fileno(f);
for (i=0; i<TSIZE; i+= 65536)
read(fd, buf, 65536);
start(f);
while (getc(f) != EOF);
end();
start(f);
while (fread(buf, 1, 256, f) > 0);
end();
start(f);
while (fgets(buf, 64436, f));
end();
printf("\n");
}
int
main(int argc, char **argv)
{
if (argc > 1 && strcmp(argv[1],"-v") == 0)
verbose = 1;
setbuf(stdout, 0);
printf(" ----- text ----- ---- binary ----\n");
printf("linesz cr getc fread fgets getc fread fgets\n");
test(4, 0);
test(64, 0);
test(4096, 0);
test(4, 1);
test(64, 1);
test(4096, 1);
remove ("iospeed.dat");
return 0;
}