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); 188long long getusecs(); 189long long getnsecs(); 190int setfdlimit(int limit); 191long long sizetoll(); 192int sizetoint(); 193int fit_line(double *, double *, int, double *, double *); 194long long get_nsecs_resolution(); 195 196#endif /* LIBMICRO_H */ 197