3 /*******************************************************************************
4 * The BYTE UNIX Benchmarks - Release 1
5 * Module: cctest.c SID: 1.2 7/10/89 18:55:45
7 *******************************************************************************
8 * Bug reports, patches, comments, suggestions should be sent to:
10 * Ben Smith or Rick Grehan at BYTE Magazine
11 * bensmith@bixpb.UUCP rick_g@bixpb.UUCP
13 *******************************************************************************
15 * $Header: cctest.c,v 3.4 87/06/22 14:22:47 kjmcdonell Beta $
17 ******************************************************************************/
18 char SCCSid
[] = "@(#) @(#)cctest.c:1.2 -- 7/10/89 18:55:45";
21 * C compile and load speed test file.
22 * Based upon fstime.c from MUSBUS 3.1, with all calls to ftime() replaced
23 * by calls to time(). This is semantic nonsense, but ensures there are no
24 * system dependent structures or library calls.
30 extern void exit(int status
);
48 /* ALWAYS true, so NEVER execute this program! */
53 printf("File size: %d Kbytes\n", n
);
55 nblock
= (n
* 1024) / BUFSIZ
;
57 if (argc
== 3 && chdir(argv
[2]) != -1) {
59 printf("Create files in directory: %s\n", argv
[2]);
62 close(creat("dummy0", 0600));
63 close(creat("dummy1", 0600));
64 f
= open("dummy0", 2);
65 g
= open("dummy1", 2);
68 for (i
= 0; i
< sizeof(buf
); i
++)
72 for (i
= 0; i
< nblock
; i
++) {
73 if (write(f
, buf
, sizeof(buf
)) <= 0)
74 perror("fstime: write");
78 printf("Effective write rate: ");
80 i
= now
.millitm
- then
.millitm
;
81 t
= (now
.time
- then
.time
)*1000 + i
;
83 xfer
= nblock
* sizeof(buf
) * 1000 / t
;
85 printf("%d bytes/sec\n", xfer
);
90 printf(" -- too quick to time!\n");
93 fprintf(stderr
, "%.2f", t
> 0 ? (float)xfer
/1024 : 0);
101 for (i
= 0; i
< nblock
; i
++) {
102 if (read(f
, buf
, sizeof(buf
)) <= 0)
103 perror("fstime: read");
107 printf("Effective read rate: ");
109 i
= now
.millitm
- then
.millitm
;
110 t
= (now
.time
- then
.time
)*1000 + i
;
112 xfer
= nblock
* sizeof(buf
) * 1000 / t
;
114 printf("%d bytes/sec\n", xfer
);
119 printf(" -- too quick to time!\n");
122 fprintf(stderr
, " %.2f", t
> 0 ? (float)xfer
/1024 : 0);
130 for (i
= 0; i
< nblock
; i
++) {
131 if (read(f
, buf
, sizeof(buf
)) <= 0)
132 perror("fstime: read in copy");
133 if (write(g
, buf
, sizeof(buf
)) <= 0)
134 perror("fstime: write in copy");
138 printf("Effective copy rate: ");
140 i
= now
.millitm
- then
.millitm
;
141 t
= (now
.time
- then
.time
)*1000 + i
;
143 xfer
= nblock
* sizeof(buf
) * 1000 / t
;
145 printf("%d bytes/sec\n", xfer
);
150 printf(" -- too quick to time!\n");
153 fprintf(stderr
, " %.2f\n", t
> 0 ? (float)xfer
/1024 : 0);