12633Sahl#
22633Sahl# CDDL HEADER START
32633Sahl#
42633Sahl# The contents of this file are subject to the terms of the
52633Sahl# Common Development and Distribution License (the "License").
62633Sahl# You may not use this file except in compliance with the License.
72633Sahl#
82633Sahl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
92633Sahl# or http://www.opensolaris.org/os/licensing.
102633Sahl# See the License for the specific language governing permissions
112633Sahl# and limitations under the License.
122633Sahl#
132633Sahl# When distributing Covered Code, include this CDDL HEADER in each
142633Sahl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
152633Sahl# If applicable, add the following below this CDDL HEADER, with the
162633Sahl# fields enclosed by brackets "[]" replaced with your own identifying
172633Sahl# information: Portions Copyright [yyyy] [name of copyright owner]
182633Sahl#
192633Sahl# CDDL HEADER END
202633Sahl#
212633Sahl
222633Sahl#
232633Sahl# Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
242633Sahl# Use is subject to license terms.
252633Sahl#
262633Sahl#ident	"%Z%%M%	%I%	%E% SMI"
272633Sahl
282633Sahlscript()
292633Sahl{
30*2804Stomee	$dtrace -s /dev/stdin -x bufpolicy=$1 $1 <<EOF
312633Sahl
322633Sahl	#pragma D option quiet
332633Sahl	#pragma D option statusrate=1hz
342633Sahl
352633Sahl	uint64_t total;
362633Sahl	int thresh;
372633Sahl
382633Sahl	BEGIN
392633Sahl	{
402633Sahl		start = timestamp;
412633Sahl		thresh = 10;
422633Sahl	}
432633Sahl
442633Sahl	sched:::on-cpu
452633Sahl	/pid == \$pid/
462633Sahl	{
472633Sahl		self->on = vtimestamp;
482633Sahl	}
492633Sahl
502633Sahl	sched:::off-cpu
512633Sahl	/self->on/
522633Sahl	{
532633Sahl		total += vtimestamp - self->on;
542633Sahl	}
552633Sahl
562633Sahl	tick-1sec
572633Sahl	/i++ == 10/
582633Sahl	{
592633Sahl		exit(0);
602633Sahl	}
612633Sahl
622633Sahl	END
632633Sahl	/((total * 100) / (timestamp - start)) > thresh/
642633Sahl	{
652633Sahl		printf("'%s' buffering policy took %d%% of CPU; ",
662633Sahl		    \$\$1, ((total * 100) / (timestamp - start)));
672633Sahl		printf("expected no more than %d%%!\n", thresh);
682633Sahl		exit(1);
692633Sahl	}
702633SahlEOF
712633Sahl}
722633Sahl
73*2804Stomeeif [ $# != 1 ]; then
74*2804Stomee	echo expected one argument: '<'dtrace-path'>'
75*2804Stomee	exit 2
76*2804Stomeefi
77*2804Stomee
78*2804Stomeedtrace=$1
79*2804Stomee
802633Sahlfor policy in "fill ring switch"; do
812633Sahl	script $policy
822633Sahl
832633Sahl	status=$?
842633Sahl
852633Sahl	if [ "$status" -ne 0 ]; then
862633Sahl		exit $status
872633Sahl	fi
882633Sahldone
892633Sahl
902633Sahlexit 0
91