0N/A * The contents of this file are subject to the terms 0N/A * of the Common Development and Distribution License 0N/A * (the "License"). You may not use this file except 0N/A * in compliance with the License. 0N/A * You can obtain a copy of the license at 0N/A * See the License for the specific language governing 0N/A * permissions and limitations under the License. 0N/A * When distributing Covered Code, include this CDDL 0N/A * HEADER in each file and include the License file at 0N/A * add the following below this CDDL HEADER, with the 0N/A * fields enclosed by brackets "[]" replaced with your 0N/A * own identifying information: Portions Copyright [yyyy] 0N/A * [name of copyright owner] 9N/A * Copyright 2007 Sun Microsystems, Inc. All rights reserved. 0N/A * Use is subject to license terms. 0N/A * benchmarking routines 0N/A * user visible globals 9N/A * default on fast platform, should be overridden by individual 0N/A * benchmarks if significantly wrong in either direction. 0N/A * Globals we do not export to the user 0N/A * Forward references 0N/A * main routine; renamed in this file to allow linking with other 0N/A (
void)
printf(
"LIBMICRO_HZ needed but not set\n");
0N/A /* before we do anything */ 0N/A * squirrel away the path to the current 0N/A * binary in a way that works on both 0N/A * Parse command line arguments 0N/A /* deal with implicit and overriding options */ 0N/A * neither benchmark or user has specified the number 0N/A * now that the options are set 0N/A /* allocate dynamic data */ 0N/A /* check that the case defines lm_tsdsize before proceeding */ 0N/A "lm_tsdsize not set\n");
0N/A /* round up tsdsize to nearest 128 to eliminate false sharing */ 0N/A /* allocate sufficient TSD for each thread in each process */ 0N/A /* initialise worker synchronisation */ 0N/A /* need this here so that parent and children can call exit() */ 0N/A /* when we started and when to stop */ 0N/A /* single process, non-fork mode */ 0N/A /* create worker processes */ 0N/A /* wait for worker processes */ 0N/A /* compute results */ 0N/A /* print arguments benchmark was invoked with ? */ 0N/A /* print result header (unless suppressed) */ 0N/A (
void)
printf(
"%12s %3s %3s %12s %12s %8s %8s %s\n",
0N/A (
void)
printf(
"%-12s %3d %3d %12.5f %12d %8lld %8d %s\n",
0N/A /* just incase something goes awry */ 0N/A /* cleanup by stages */ 0N/A /* wait for it ... */ 0N/A /* record results and sync */ 0N/A " [-1] (single process; overrides -P > 1)\n" 0N/A " [-A] (align with clock)\n" 0N/A " [-B batch-size (default %d)]\n" 0N/A " [-C minimum number of samples (default 0)]\n" 0N/A " [-D duration in msecs (default %ds)]\n" 0N/A " [-E (echo name to stderr)]\n" 0N/A " [-H] (suppress headers)\n" 0N/A " [-I] nsecs per op (used to compute batch size)" 0N/A " [-L] (print argument line)\n" 0N/A " [-M] (reports mean rather than median)\n" 0N/A " [-N test-name (default '%s')]\n" 0N/A " [-P processes (default %d)]\n" 0N/A " [-S] (print detailed stats)\n" 0N/A " [-T threads (default %d)]\n" 0N/A " [-V] (print the libMicro version and exit)\n" 0N/A " [-W] (flag possible benchmark problems)\n" 9N/A "increase batch size (-B option) %dX to avoid.\n",
9N/A * XXX should warn on median != mean by a lot 9N/A (
void)
printf(
"# Errors occured during benchmark.\n");
9N/A (
void)
printf(
"# standard error %12.5f %12.5f\n",
9N/A (
void)
printf(
"# 99%% confidence level %12.5f %12.5f\n",
9N/A (
void)
printf(
"# time correlation %12.5f %12.5f\n",
0N/A /* first thread only */ 0N/A /* all but first thread */ 0N/A /* last thread only */ 0N/A * normalize by procs * threads if not -U 0N/A /* [hwm - 1, 0, 0] */ 0N/A * if ! nowait {s1(-(hwm-1))} 0N/A * (all other threads) 0N/A * update shared stats 0N/A * {s0(hwm-1), s1(1)} 0N/A * update shared stats 0N/A /* all but the last thread */ 0N/A /* the last thread */ 0N/A#
else /* USE_SEMOP */ 0N/A#
endif /* USE_SEMOP */ 0N/A unsigned long long x;
0N/A#
else /* USE_GETHRTIME */ 0N/A#
endif /* USE_GETHRTIME */ 0N/A return (0);
/* no worries */ 9N/A double a = *((
double *)
p1);
9N/A double b = *((
double *)
p2);
0N/A /* calculate how much data we've captured */ 0N/A /* find the 95th percentile - index, value and range */ 0N/A /* find a suitable min and scale */ 0N/A y = x +
0.9999999999;
0N/A /* create and initialise the histogram */ 0N/A /* populate the histogram */ 0N/A /* find the larges bucket */ 0N/A /* print the buckets */ 0N/A /* find the mean of values beyond the 95th percentile */ 0N/A /* print the >95% bucket summary */ 0N/A /* quantify any buffer overflow */ 0N/A (
void)
printf(
"# %12s %12d\n",
"data dropped",
0N/A * recursively apply 3 sigma rule to remove outliers 0N/A * routine to compute various statistics on array of doubles. 0N/A * first we need the mean 0N/A * malloc and sort so we can do median 0N/A * reuse dupdata to compute time correlation of data to 0N/A * detect interesting time-based trends 0N/A * does a least squares fit to the set of points x, y and 0N/A * fits a line y = a + bx. Returns a, b 0N/A * empty function for measurement purposes 11N/A * Determine the resolution of the system's high resolution counter. 11N/A * Most hardware has a nanosecond resolution counter, but some systems still 11N/A * use course resolution (e.g. derived instead by a periodic interrupt). 11N/A * Determine a busy loop that is long enough for successive nanosecond counter 11N/A * reads to report different times. Then take 1000 samples with busy loop 11N/A * interval successively increases by i. The counter resolution is assumed 11N/A * to be the smallest non-zero time delta between these 1000 samples. 11N/A * One last wrinkle is all 1000 samples may have the same delta on a system 11N/A * with a very fast and consistent hardware counter based getnsecs(). 11N/A * In that case assume the resolution is 1ns. 0N/A * first, figure out how many nops to use 0N/A * to get any delta between time measurements. 0N/A * use a minimum of one. 0N/A for (i =
1; i <
10000000; i++) {
0N/A * now collect data at linearly varying intervals 0N/A for (i = 0; i <
1000; i++) {
0N/A * find smallest positive difference between samples; 11N/A * this is the counter resolution 0N/A for (i =
1; i <
1000; i++) {
0N/A * remove any data points from the array more than 3 sigma out