-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathlibmicro.h
196 lines (160 loc) · 4.45 KB
/
libmicro.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef LIBMICRO_H
#define LIBMICRO_H
#include <pthread.h>
#define LIBMICRO_VERSION "0.4.1"
#define STRSIZE 1024
typedef struct {
long long re_count;
long long re_errors;
long long re_t0;
long long re_t1;
} result_t;
typedef struct {
double sum;
long long count;
} histo_t;
#define HISTOSIZE 32
#define DATASIZE 100000
/*
* stats we compute on data sets
*/
typedef struct stats {
double st_min;
double st_max;
double st_mean;
double st_median;
double st_stddev;
double st_stderr;
double st_99confidence;
double st_skew;
double st_kurtosis;
double st_timecorr; /* correlation with respect to time */
} stats_t;
/*
* Barrier stuff
*/
typedef struct {
int ba_hwm; /* barrier setpoint */
int ba_flag; /* benchmark while true */
long long ba_deadline; /* when to stop */
int ba_phase; /* number of time used */
int ba_waiters; /* how many are waiting */
#ifdef USE_SEMOP
int ba_semid;
#else
pthread_mutex_t ba_lock;
pthread_cond_t ba_cv;
#endif
long long ba_count; /* how many ops */
long long ba_errors; /* how many errors */
int ba_quant; /* how many quant errors */
int ba_batches; /* how many samples */
double ba_starttime; /* test time start */
double ba_endtime; /* test time end */
#ifdef NEVER
double ba_tmin; /* min time taken */
double ba_tmax; /* max time taken */
double ba_ctmax; /* max after outliers */
double ba_mean; /* average value */
double ba_median; /* median value */
double ba_rawmedian; /* raw median value */
double ba_stddev; /* standard deviation */
double ba_stderr; /* standard error */
double ba_skew; /* skew */
double ba_kurtosis; /* kurtosis */
#endif
stats_t ba_raw; /* raw stats */
stats_t ba_corrected; /* corrected stats */
int ba_outliers; /* outlier count */
long long ba_t0; /* first thread/proc */
long long ba_t1; /* time of last thread */
long long ba_count0;
long long ba_errors0;
int ba_datasize; /* possible #items data */
double ba_data[1]; /* start of data ararry */
} barrier_t;
/*
* Barrier interfaces
*/
barrier_t *barrier_create(int hwm, int datasize);
int barrier_destroy(barrier_t *bar);
int barrier_queue(barrier_t *bar, result_t *res);
/*
* Functions that can be provided by the user
*/
int benchmark(void *tsd, result_t *res);
int benchmark_init();
int benchmark_fini();
int benchmark_initrun();
int benchmark_finirun();
int benchmark_initworker();
int benchmark_finiworker();
int benchmark_initbatch(void *tsd);
int benchmark_finibatch(void *tsd);
int benchmark_optswitch(int opt, char *optarg);
char *benchmark_result();
/*
* Globals exported to the user
*/
extern int lm_argc;
extern char **lm_argv;
extern int lm_optB;
extern int lm_optD;
extern int lm_optH;
extern char *lm_optN;
extern int lm_optP;
extern int lm_optS;
extern int lm_optT;
extern int lm_defB;
extern int lm_defD;
extern int lm_defH;
extern char *lm_defN;
extern int lm_defP;
extern int lm_defS;
extern int lm_defT;
extern int lm_nsecs_per_op;
extern char *lm_procpath;
extern char lm_procname[STRSIZE];
extern char lm_usage[STRSIZE];
extern char lm_optstr[STRSIZE];
extern char lm_header[STRSIZE];
extern size_t lm_tsdsize;
/*
* Utility functions
*/
int getpindex();
int gettindex();
void *gettsd(int p, int t);
long long getusecs();
long long getnsecs();
int setfdlimit(int limit);
long long sizetoll();
int sizetoint();
int fit_line(double *, double *, int, double *, double *);
long long get_nsecs_resolution();
#endif /* LIBMICRO_H */