]>
git.saurik.com Git - apple/xnu.git/blob - tools/tests/libMicro/libmicro.h
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
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.
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]
24 * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
25 * Use is subject to license terms.
33 #define LIBMICRO_VERSION "0.4.0"
37 #define STREQ(a,b) (strcmp(a,b) == 0)
52 #define DATASIZE 100000
55 * stats we compute on data sets
58 typedef struct stats
{
65 double st_99confidence
;
68 double st_timecorr
; /* correlation with respect to time */
76 int ba_hwm
; /* barrier setpoint */
77 int ba_flag
; /* benchmark while true */
78 long long ba_deadline
; /* when to stop */
79 int ba_phase
; /* number of time used */
80 int ba_waiters
; /* how many are waiting */
85 pthread_mutex_t ba_lock
;
89 long long ba_count
; /* how many ops */
90 long long ba_errors
; /* how many errors */
92 int ba_quant
; /* how many quant errors */
93 int ba_batches
; /* how many samples */
95 double ba_starttime
; /* test time start */
96 double ba_endtime
; /* test time end */
99 double ba_tmin
; /* min time taken */
100 double ba_tmax
; /* max time taken */
101 double ba_ctmax
; /* max after outliers */
102 double ba_mean
; /* average value */
103 double ba_median
; /* median value */
104 double ba_rawmedian
; /* raw median value */
105 double ba_stddev
; /* standard deviation */
106 double ba_stderr
; /* standard error */
107 double ba_skew
; /* skew */
108 double ba_kurtosis
; /* kurtosis */
110 stats_t ba_raw
; /* raw stats */
111 stats_t ba_corrected
; /* corrected stats */
113 int ba_outliers
; /* outlier count */
115 long long ba_t0
; /* first thread/proc */
116 long long ba_t1
; /* time of last thread */
118 long long ba_errors0
;
120 int ba_datasize
; /* possible #items data */
121 double ba_data
[1]; /* start of data ararry */
129 barrier_t
*barrier_create(int hwm
, int datasize
);
130 int barrier_destroy(barrier_t
*bar
);
131 int barrier_queue(barrier_t
*bar
, result_t
*res
);
135 * Functions that can be provided by the user
138 int benchmark(void *tsd
, result_t
*res
);
139 int benchmark_init();
140 int benchmark_fini();
141 int benchmark_initrun();
142 int benchmark_finirun();
143 int benchmark_initworker();
144 int benchmark_finiworker();
145 int benchmark_initbatch(void *tsd
);
146 int benchmark_finibatch(void *tsd
);
147 int benchmark_optswitch(int opt
, char *optarg
);
148 char *benchmark_result();
152 * Globals exported to the user
156 extern char **lm_argv
;
161 extern char *lm_optN
;
169 extern char *lm_defN
;
173 extern int lm_nsecs_per_op
;
175 extern char *lm_procpath
;
176 extern char lm_procname
[STRSIZE
];
177 extern char lm_usage
[STRSIZE
];
178 extern char lm_optstr
[STRSIZE
];
179 extern char lm_header
[STRSIZE
];
180 extern size_t lm_tsdsize
;
189 void *gettsd(int p
, int t
);
190 #if defined(__APPLE__)
191 int gettsdindex(void *arg
);
192 #endif /* __APPLE__ */
193 long long getusecs();
194 long long getnsecs();
195 int setfdlimit(int limit
);
196 long long sizetoll();
198 int fit_line(double *, double *, int, double *, double *);
199 long long get_nsecs_resolution();
202 /* Apple Mods Here */
207 #define TCP_SELECT -31233
208 #define TCP_XACT -31234
209 #define TCP_CONTROL -31235
210 #define TCP_DATA -31236
211 #define TCP_CONNECT -31237
212 #define UDP_XACT -31238
213 #define UDP_DATA -31239
215 #define TCP_SELECT (u_long)404038 /* XXX - unregistered */
216 #define TCP_XACT (u_long)404039 /* XXX - unregistered */
217 #define TCP_CONTROL (u_long)404040 /* XXX - unregistered */
218 #define TCP_DATA (u_long)404041 /* XXX - unregistered */
219 #define TCP_CONNECT (u_long)404042 /* XXX - unregistered */
220 #define UDP_XACT (u_long)404032 /* XXX - unregistered */
221 #define UDP_DATA (u_long)404033 /* XXX - unregistered */
222 #define VERS (u_long)1
226 * socket send/recv buffer optimizations
228 #define SOCKOPT_READ 0x0001
229 #define SOCKOPT_WRITE 0x0002
230 #define SOCKOPT_RDWR 0x0003
231 #define SOCKOPT_PID 0x0004
232 #define SOCKOPT_REUSE 0x0008
233 #define SOCKOPT_NONE 0
236 #define SOCKBUF (1024*1024)
240 #define XFERSIZE (64*1024) /* all bandwidth I/O should use this */
243 typedef unsigned long iter_t
;
245 int tcp_server(int prog
, int rdwr
);
246 int tcp_done(int prog
);
247 int tcp_accept(int sock
, int rdwr
);
248 int tcp_connect(char *host
, int prog
, int rdwr
);
249 void sock_optimize(int sock
, int rdwr
);
255 #endif /* LIBMICRO_H */