0N/A/*
0N/A * CDDL HEADER START
0N/A *
0N/A * The contents of this file are subject to the terms of the
0N/A * Common Development and Distribution License, Version 1.0 only
0N/A * (the "License"). You may not use this file except in compliance
0N/A * with the License.
0N/A *
0N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0N/A * or http://www.opensolaris.org/os/licensing.
0N/A * See the License for the specific language governing permissions
0N/A * and limitations under the License.
0N/A *
0N/A * When distributing Covered Code, include this CDDL HEADER in each
0N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0N/A * If applicable, add the following below this CDDL HEADER, with the
0N/A * fields enclosed by brackets "[]" replaced with your own identifying
0N/A * information: Portions Copyright [yyyy] [name of copyright owner]
0N/A *
0N/A * CDDL HEADER END
0N/A */
0N/A
0N/A/*
9N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved.
0N/A * Use is subject to license terms.
0N/A */
0N/A
0N/A#ifndef LIBMICRO_H
0N/A#define LIBMICRO_H
0N/A
0N/A#include <pthread.h>
0N/A
14N/A#define LIBMICRO_VERSION "0.4.2"
0N/A
0N/A#define STRSIZE 1024
0N/A
0N/Atypedef struct {
0N/A long long re_count;
0N/A long long re_errors;
0N/A long long re_t0;
0N/A long long re_t1;
0N/A} result_t;
0N/A
0N/Atypedef struct {
0N/A double sum;
0N/A long long count;
0N/A} histo_t;
0N/A
0N/A#define HISTOSIZE 32
0N/A#define DATASIZE 100000
0N/A
0N/A/*
0N/A * stats we compute on data sets
0N/A */
0N/A
0N/Atypedef struct stats {
0N/A double st_min;
0N/A double st_max;
0N/A double st_mean;
0N/A double st_median;
0N/A double st_stddev;
0N/A double st_stderr;
0N/A double st_99confidence;
0N/A double st_skew;
0N/A double st_kurtosis;
0N/A double st_timecorr; /* correlation with respect to time */
0N/A} stats_t;
0N/A
0N/A/*
0N/A * Barrier stuff
0N/A */
0N/A
0N/Atypedef struct {
0N/A int ba_hwm; /* barrier setpoint */
0N/A int ba_flag; /* benchmark while true */
0N/A long long ba_deadline; /* when to stop */
0N/A int ba_phase; /* number of time used */
0N/A int ba_waiters; /* how many are waiting */
0N/A
0N/A#ifdef USE_SEMOP
0N/A int ba_semid;
0N/A#else
0N/A pthread_mutex_t ba_lock;
0N/A pthread_cond_t ba_cv;
0N/A#endif
0N/A
9N/A long long ba_count; /* how many ops */
9N/A long long ba_errors; /* how many errors */
0N/A
9N/A int ba_quant; /* how many quant errors */
9N/A int ba_batches; /* how many samples */
0N/A
0N/A double ba_starttime; /* test time start */
0N/A double ba_endtime; /* test time end */
0N/A
0N/A#ifdef NEVER
0N/A double ba_tmin; /* min time taken */
0N/A double ba_tmax; /* max time taken */
0N/A double ba_ctmax; /* max after outliers */
0N/A double ba_mean; /* average value */
0N/A double ba_median; /* median value */
0N/A double ba_rawmedian; /* raw median value */
0N/A double ba_stddev; /* standard deviation */
0N/A double ba_stderr; /* standard error */
0N/A double ba_skew; /* skew */
0N/A double ba_kurtosis; /* kurtosis */
0N/A#endif
0N/A stats_t ba_raw; /* raw stats */
0N/A stats_t ba_corrected; /* corrected stats */
0N/A
0N/A int ba_outliers; /* outlier count */
9N/A
0N/A long long ba_t0; /* first thread/proc */
9N/A long long ba_t1; /* time of last thread */
0N/A long long ba_count0;
0N/A long long ba_errors0;
0N/A
0N/A int ba_datasize; /* possible #items data */
0N/A double ba_data[1]; /* start of data ararry */
0N/A} barrier_t;
0N/A
0N/A
0N/A/*
0N/A * Barrier interfaces
0N/A */
0N/A
0N/Abarrier_t *barrier_create(int hwm, int datasize);
0N/Aint barrier_destroy(barrier_t *bar);
0N/Aint barrier_queue(barrier_t *bar, result_t *res);
0N/A
0N/A
0N/A/*
0N/A * Functions that can be provided by the user
0N/A */
0N/A
0N/Aint benchmark(void *tsd, result_t *res);
0N/Aint benchmark_init();
0N/Aint benchmark_fini();
0N/Aint benchmark_initrun();
0N/Aint benchmark_finirun();
0N/Aint benchmark_initworker();
0N/Aint benchmark_finiworker();
0N/Aint benchmark_initbatch(void *tsd);
0N/Aint benchmark_finibatch(void *tsd);
0N/Aint benchmark_optswitch(int opt, char *optarg);
0N/Achar *benchmark_result();
0N/A
0N/A
0N/A/*
0N/A * Globals exported to the user
0N/A */
0N/A
0N/Aextern int lm_argc;
0N/Aextern char **lm_argv;
0N/A
0N/Aextern int lm_optB;
0N/Aextern int lm_optD;
0N/Aextern int lm_optH;
0N/Aextern char *lm_optN;
0N/Aextern int lm_optP;
0N/Aextern int lm_optS;
0N/Aextern int lm_optT;
0N/A
0N/Aextern int lm_defB;
0N/Aextern int lm_defD;
0N/Aextern int lm_defH;
0N/Aextern char *lm_defN;
0N/Aextern int lm_defP;
0N/Aextern int lm_defS;
0N/Aextern int lm_defT;
0N/Aextern int lm_nsecs_per_op;
0N/A
0N/Aextern char *lm_procpath;
0N/Aextern char lm_procname[STRSIZE];
0N/Aextern char lm_usage[STRSIZE];
0N/Aextern char lm_optstr[STRSIZE];
0N/Aextern char lm_header[STRSIZE];
0N/Aextern size_t lm_tsdsize;
0N/A
0N/A
0N/A/*
0N/A * Utility functions
0N/A */
0N/A
0N/Aint getpindex();
0N/Aint gettindex();
0N/Avoid *gettsd(int p, int t);
0N/Along long getusecs();
0N/Along long getnsecs();
0N/Aint setfdlimit(int limit);
0N/Along long sizetoll();
0N/Aint sizetoint();
0N/Aint fit_line(double *, double *, int, double *, double *);
0N/Along long get_nsecs_resolution();
0N/A
0N/A#endif /* LIBMICRO_H */