1 /**************************************************************************
3 * Copyright (C) 1995 Silicon Graphics, Inc. *
5 * These coded instructions, statements, and computer programs were *
6 * developed by SGI for public use. If any changes are made to this code*
7 * please try to get the changes back to the author. Feel free to make *
8 * modifications and changes to the code and release it. *
10 **************************************************************************/
19 #define USECINSEC 1000000
20 #define MSECINSEC 1000
21 #define MAX_ACCEPT_SECS 180 /* maximum time master will wait for listen() */
24 #define MAXCLIENTS 1024
25 #define MAXUSERNAME 25
29 #define MAXTOTALPROCS MAXCLIENTS /* overall max # of procs */
30 #define MAXPROCSPERNODE MAXCLIENTS /* max # of procs/node */
33 #define CONTENT_LENGTH_STRING "CONTENT-LENGTH:"
35 #define OKSTRLEN ((int)strlen(OKSTR))
37 #define GOSTRLEN ((int)strlen(GOSTR))
38 #define READYSTR "READY"
39 #define READYSTRLEN ((int)strlen(READYSTR))
40 #define ABORTSTR "ABORT"
41 #define ABORTSTRLEN ((int)strlen(ABORTSTR))
44 #define MAXNUMOFFILES 1 /* max # of files per page */
46 #define MAXNUMOFPAGES 100
47 #define SIZEOF_TIMEVALTEXT 18
48 #define SIZEOF_DOUBLETEXT 18
49 #define SIZEOF_RQSTSTATSTEXT ((7 * SIZEOF_TIMEVALTEXT) + \
50 (12 * SIZEOF_DOUBLETEXT) + 1)
51 #define SIZEOF_STATSTEXTBASE (SIZEOF_RQSTSTATSTEXT + \
52 (3 * SIZEOF_TIMEVALTEXT) + \
53 (2 * SIZEOF_DOUBLETEXT) + 1)
54 #define SIZEOF_STATSTEXT (SIZEOF_STATSTEXTBASE + MAXNUMOFPAGES * SIZEOF_DOUBLETEXT)
55 #define SIZEOF_PAGESTATSTEXT (SIZEOF_RQSTSTATSTEXT + \
56 (0 * SIZEOF_TIMEVALTEXT) + \
57 (3 * SIZEOF_DOUBLETEXT) + 1)
59 #define D_PRINTF debug && d_printf
62 typedef struct rqst_timer
{
63 struct timeval entertime
;
64 struct timezone entertimezone
;
65 struct timeval beforeconnect
;
66 struct timezone beforeconnectzone
;
67 struct timeval afterconnect
;
68 struct timezone afterconnectzone
;
69 struct timeval beforeheader
;
70 struct timezone beforeheaderzone
;
71 struct timeval afterheader
;
72 struct timezone afterheaderzone
;
73 struct timeval afterbody
;
74 struct timezone afterbodyzone
;
75 struct timeval exittime
;
76 struct timezone exittimezone
;
77 long unsigned int totalbytes
;
78 long unsigned int bodybytes
;
80 long unsigned int page_number
;
83 typedef struct rqst_timer
{
84 struct timeval entertime
;
85 struct timeval beforeconnect
;
86 struct timeval afterconnect
;
87 struct timeval beforeheader
;
88 struct timeval afterheader
;
89 struct timeval afterbody
;
90 struct timeval exittime
;
91 long unsigned int totalbytes
;
92 long unsigned int bodybytes
;
94 long unsigned int page_number
;
96 #endif /* USE_TIMEZONE */
98 extern void rqtimer_init(rqst_timer_t
*);
101 typedef struct rqst_stats
{
102 struct timeval totalresponsetime
;
103 struct timezone totalresponsetimezone
;
104 double totalresponsetimesq
;
105 struct timeval minresponsetime
;
106 struct timezone minresponsetimezone
;
107 struct timeval maxresponsetime
;
108 struct timezone maxresponsetimezone
;
109 struct timeval totalconnecttime
;
110 struct timezone totalconnecttimezone
;
111 double totalconnecttimesq
;
112 struct timeval minconnecttime
;
113 struct timezone minconnecttimezone
;
114 struct timeval maxconnecttime
;
115 struct timezone maxconnecttimezone
;
116 long unsigned int totalconnects
;
117 long unsigned int totalerrs
;
118 struct timeval totalerrortime
;
119 struct timezone totalerrortimezone
;
130 typedef struct rqst_stats
{
131 struct timeval totalresponsetime
;
132 double totalresponsetimesq
;
133 struct timeval minresponsetime
;
134 struct timeval maxresponsetime
;
135 struct timeval totalconnecttime
;
136 double totalconnecttimesq
;
137 struct timeval minconnecttime
;
138 struct timeval maxconnecttime
;
139 long unsigned int totalconnects
;
140 long unsigned int totalerrs
;
141 struct timeval totalerrortime
;
151 #endif /* USE_TIMEZONE */
153 extern void rqstat_init(rqst_stats_t
*);
154 extern void rqstat_sum(rqst_stats_t
*, rqst_stats_t
*);
155 extern void rqstat_print(rqst_stats_t
*);
156 extern void rqstat_fprint(FILE *, rqst_stats_t
*);
157 extern void rqstat_times(rqst_stats_t
*, rqst_timer_t
*);
160 typedef struct stats
{
161 /* char hostname[MAXHOSTNAMELEN]; */
163 struct timeval starttime
;
164 struct timezone starttimezone
;
165 struct timeval endtime
;
166 struct timezone endtimezone
;
167 struct timeval datatime
;
168 struct timezone datatimezone
;
169 long unsigned int totalpages
;
170 unsigned int total_num_of_files
;
171 unsigned int page_numbers
[MAXNUMOFPAGES
];
174 typedef struct stats
{
175 /* char hostname[MAXHOSTNAMELEN]; */
177 struct timeval starttime
;
178 struct timeval endtime
;
179 struct timeval datatime
;
180 long unsigned int totalpages
;
181 unsigned int total_num_of_files
;
182 unsigned int page_numbers
[MAXNUMOFPAGES
];
184 #endif /* USE_TIMEZONE */
186 extern void stats_init(stats_t
*);
187 extern stats_t
* text_to_stats(char *);
188 extern char * stats_to_text(const stats_t
*);
190 typedef struct page_stats
{
192 long unsigned int totalpages
;
193 unsigned int page_size
;
197 extern void page_stats_init(page_stats_t
*);
198 extern page_stats_t
* text_to_page_stats(char *);
199 extern char * page_stats_to_text(const page_stats_t
*);
201 /* THIS STRUCTURE DEFINES A PAGE. */
202 typedef struct page_list
{
205 char *(filename
[MAXNUMOFFILES
]);
206 char *(servername
[MAXNUMOFFILES
]);
207 int port_number
[MAXNUMOFFILES
];
211 /* shared variables */
212 extern THREAD
FILE *debugfile
;
216 extern int timeexpired
;
217 extern long int number_of_pages
;
219 /* routines in bench.c */
221 extern void *mymalloc(size_t size
);
222 extern int recvdata(SOCKET sock
, char *ptr
, int nbytes
);
223 extern int senddata(SOCKET sock
, char *ptr
, int nbytes
);
224 extern void rqstat_times(rqst_stats_t
*rs
, rqst_timer_t
*rt
);
225 /* note several others listed above */
227 /* routines in errexit.c */
229 void errexit(const char *, ...);
230 extern int returnerr(const char *, ...);
231 extern int d_printf(const char *, ...);
232 extern char *neterrstr();
234 /* routines in get.c */
236 extern int get(char *loc
, NETPORT port
, char *url
, rqst_timer_t
*timer
);
238 /* routines in parse_file_list.c */
240 extern int count_file_list(const char *url_list_file
);
241 extern void parse_file_list (const char *url_list_file
, page_list_t
*page_list
,
242 long int *num_of_pages
, long int *num_of_files
);
243 extern long int load_percent(page_list_t
*page_list
, long int number_of_pages
);
245 /* routines in statistics.c (formerly statistics.h) */
247 extern double mean(const double, const int);
248 extern double variance(const double, const double, const int);
249 extern double stddev(const double, const double, const int);
251 /* routines in timefunc.c (formerly timefunc.h) */
253 extern double timevaldouble(struct timeval
*);
254 extern void doubletimeval(const double, struct timeval
*);
256 extern void addtime(struct timeval
*, struct timeval
*);
257 extern void compdifftime(struct timeval
*, struct timeval
*, struct timeval
*);
258 extern void mintime(struct timeval
*, struct timeval
*);
259 extern void maxtime(struct timeval
*, struct timeval
*);
260 extern void avgtime(struct timeval
*, int, struct timeval
*);
261 extern void variancetime(struct timeval
*, double, int, struct timeval
*);
262 extern void stddevtime(struct timeval
*, double, int, struct timeval
*);
264 extern void sqtime(struct timeval
*, struct timeval
*);
266 extern double thruputpersec(const double, struct timeval
*);
268 /* routines in webclient.c */
270 extern SOCKET
connectsock(char *host
, NETPORT portnum
, char *protocol
);
272 #endif /* !__BENCH_H__ */