]> git.saurik.com Git - apple/xnu.git/blame_incremental - tools/tests/libMicro/libmicro.h
xnu-1456.1.26.tar.gz
[apple/xnu.git] / tools / tests / libMicro / libmicro.h
... / ...
CommitLineData
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22
23/*
24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
26 */
27
28#ifndef LIBMICRO_H
29#define LIBMICRO_H
30
31#include <pthread.h>
32
33#define LIBMICRO_VERSION "0.4.0"
34
35#define STRSIZE 1024
36
37typedef struct {
38 long long re_count;
39 long long re_errors;
40 long long re_t0;
41 long long re_t1;
42} result_t;
43
44typedef struct {
45 double sum;
46 long long count;
47} histo_t;
48
49#define HISTOSIZE 32
50#define DATASIZE 100000
51
52/*
53 * stats we compute on data sets
54 */
55
56typedef struct stats {
57 double st_min;
58 double st_max;
59 double st_mean;
60 double st_median;
61 double st_stddev;
62 double st_stderr;
63 double st_99confidence;
64 double st_skew;
65 double st_kurtosis;
66 double st_timecorr; /* correlation with respect to time */
67} stats_t;
68
69/*
70 * Barrier stuff
71 */
72
73typedef struct {
74 int ba_hwm; /* barrier setpoint */
75 int ba_flag; /* benchmark while true */
76 long long ba_deadline; /* when to stop */
77 int ba_phase; /* number of time used */
78 int ba_waiters; /* how many are waiting */
79
80#ifdef USE_SEMOP
81 int ba_semid;
82#else
83 pthread_mutex_t ba_lock;
84 pthread_cond_t ba_cv;
85#endif
86
87 long long ba_count; /* how many ops */
88 long long ba_errors; /* how many errors */
89
90 int ba_quant; /* how many quant errors */
91 int ba_batches; /* how many samples */
92
93 double ba_starttime; /* test time start */
94 double ba_endtime; /* test time end */
95
96#ifdef NEVER
97 double ba_tmin; /* min time taken */
98 double ba_tmax; /* max time taken */
99 double ba_ctmax; /* max after outliers */
100 double ba_mean; /* average value */
101 double ba_median; /* median value */
102 double ba_rawmedian; /* raw median value */
103 double ba_stddev; /* standard deviation */
104 double ba_stderr; /* standard error */
105 double ba_skew; /* skew */
106 double ba_kurtosis; /* kurtosis */
107#endif
108 stats_t ba_raw; /* raw stats */
109 stats_t ba_corrected; /* corrected stats */
110
111 int ba_outliers; /* outlier count */
112
113 long long ba_t0; /* first thread/proc */
114 long long ba_t1; /* time of last thread */
115 long long ba_count0;
116 long long ba_errors0;
117
118 int ba_datasize; /* possible #items data */
119 double ba_data[1]; /* start of data ararry */
120} barrier_t;
121
122
123/*
124 * Barrier interfaces
125 */
126
127barrier_t *barrier_create(int hwm, int datasize);
128int barrier_destroy(barrier_t *bar);
129int barrier_queue(barrier_t *bar, result_t *res);
130
131
132/*
133 * Functions that can be provided by the user
134 */
135
136int benchmark(void *tsd, result_t *res);
137int benchmark_init();
138int benchmark_fini();
139int benchmark_initrun();
140int benchmark_finirun();
141int benchmark_initworker();
142int benchmark_finiworker();
143int benchmark_initbatch(void *tsd);
144int benchmark_finibatch(void *tsd);
145int benchmark_optswitch(int opt, char *optarg);
146char *benchmark_result();
147
148
149/*
150 * Globals exported to the user
151 */
152
153extern int lm_argc;
154extern char **lm_argv;
155
156extern int lm_optB;
157extern int lm_optD;
158extern int lm_optH;
159extern char *lm_optN;
160extern int lm_optP;
161extern int lm_optS;
162extern int lm_optT;
163
164extern int lm_defB;
165extern int lm_defD;
166extern int lm_defH;
167extern char *lm_defN;
168extern int lm_defP;
169extern int lm_defS;
170extern int lm_defT;
171extern int lm_nsecs_per_op;
172
173extern char *lm_procpath;
174extern char lm_procname[STRSIZE];
175extern char lm_usage[STRSIZE];
176extern char lm_optstr[STRSIZE];
177extern char lm_header[STRSIZE];
178extern size_t lm_tsdsize;
179
180
181/*
182 * Utility functions
183 */
184
185int getpindex();
186int gettindex();
187void *gettsd(int p, int t);
188#if defined(__APPLE__)
189int gettsdindex(void *arg);
190#endif /* __APPLE__ */
191long long getusecs();
192long long getnsecs();
193int setfdlimit(int limit);
194long long sizetoll();
195int sizetoint();
196int fit_line(double *, double *, int, double *, double *);
197long long get_nsecs_resolution();
198
199
200/* Apple Mods Here */
201
202
203
204#ifdef NO_PORTMAPPER
205#define TCP_SELECT -31233
206#define TCP_XACT -31234
207#define TCP_CONTROL -31235
208#define TCP_DATA -31236
209#define TCP_CONNECT -31237
210#define UDP_XACT -31238
211#define UDP_DATA -31239
212#else
213#define TCP_SELECT (u_long)404038 /* XXX - unregistered */
214#define TCP_XACT (u_long)404039 /* XXX - unregistered */
215#define TCP_CONTROL (u_long)404040 /* XXX - unregistered */
216#define TCP_DATA (u_long)404041 /* XXX - unregistered */
217#define TCP_CONNECT (u_long)404042 /* XXX - unregistered */
218#define UDP_XACT (u_long)404032 /* XXX - unregistered */
219#define UDP_DATA (u_long)404033 /* XXX - unregistered */
220#define VERS (u_long)1
221#endif
222
223/*
224* socket send/recv buffer optimizations
225*/
226#define SOCKOPT_READ 0x0001
227#define SOCKOPT_WRITE 0x0002
228#define SOCKOPT_RDWR 0x0003
229#define SOCKOPT_PID 0x0004
230#define SOCKOPT_REUSE 0x0008
231#define SOCKOPT_NONE 0
232
233#ifndef SOCKBUF
234#define SOCKBUF (1024*1024)
235#endif
236
237#ifndef XFERSIZE
238#define XFERSIZE (64*1024) /* all bandwidth I/O should use this */
239#endif
240
241typedef unsigned long iter_t;
242
243int tcp_server(int prog, int rdwr);
244int tcp_done(int prog);
245int tcp_accept(int sock, int rdwr);
246int tcp_connect(char *host, int prog, int rdwr);
247void sock_optimize(int sock, int rdwr);
248int sockport(int s);
249
250/* end Apple Mods */
251
252
253#endif /* LIBMICRO_H */