xref: /onnv-gate/usr/src/cmd/filebench/common/stats.h (revision 7736:affefef63864)
15184Sek110237 /*
25184Sek110237  * CDDL HEADER START
35184Sek110237  *
45184Sek110237  * The contents of this file are subject to the terms of the
55184Sek110237  * Common Development and Distribution License (the "License").
65184Sek110237  * You may not use this file except in compliance with the License.
75184Sek110237  *
85184Sek110237  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
95184Sek110237  * or http://www.opensolaris.org/os/licensing.
105184Sek110237  * See the License for the specific language governing permissions
115184Sek110237  * and limitations under the License.
125184Sek110237  *
135184Sek110237  * When distributing Covered Code, include this CDDL HEADER in each
145184Sek110237  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
155184Sek110237  * If applicable, add the following below this CDDL HEADER, with the
165184Sek110237  * fields enclosed by brackets "[]" replaced with your own identifying
175184Sek110237  * information: Portions Copyright [yyyy] [name of copyright owner]
185184Sek110237  *
195184Sek110237  * CDDL HEADER END
205184Sek110237  */
215184Sek110237 /*
22*7736SAndrew.W.Wilson@sun.com  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
235184Sek110237  * Use is subject to license terms.
245184Sek110237  */
255184Sek110237 
265184Sek110237 #ifndef	_FB_STATS_H
275184Sek110237 #define	_FB_STATS_H
285184Sek110237 
295184Sek110237 #include "config.h"
305184Sek110237 #ifdef HAVE_STDINT_H
315184Sek110237 #include <stdint.h>
325184Sek110237 #endif
335184Sek110237 
345184Sek110237 #ifdef	__cplusplus
355184Sek110237 extern "C" {
365184Sek110237 #endif
375184Sek110237 
385184Sek110237 var_t *stats_findvar(var_t *var, char *name);
395184Sek110237 void stats_init(void);
405184Sek110237 void stats_clear(void);
415184Sek110237 void stats_snap(void);
425184Sek110237 void stats_dump(char *filename);
435184Sek110237 void stats_xmldump(char *filename);
44*7736SAndrew.W.Wilson@sun.com void stats_multidump(char *filename);
455184Sek110237 
465184Sek110237 #ifndef HAVE_HRTIME
475184Sek110237 /* typedef uint64_t hrtime_t; */
485184Sek110237 #define	hrtime_t uint64_t
495184Sek110237 #endif
505184Sek110237 
515184Sek110237 #define	STATS_VAR "stats."
525184Sek110237 
535184Sek110237 #define	FLOW_MSTATES 4
545184Sek110237 #define	FLOW_MSTATE_LAT 0	/* Total service time of op */
555184Sek110237 #define	FLOW_MSTATE_CPU 1	/* On-cpu time of op */
565184Sek110237 #define	FLOW_MSTATE_WAIT 2	/* Wait-time, excluding waiting for CPU */
575184Sek110237 #define	FLOW_MSTATE_OHEAD 3	/* overhead time, around op */
585184Sek110237 
595184Sek110237 typedef struct flowstats {
605184Sek110237 	int		fs_children;	/* Number of contributors */
615184Sek110237 	int		fs_active;	/* Number of active contributors */
625184Sek110237 	int		fs_count;	/* Number of ops */
635184Sek110237 	uint64_t	fs_rbytes;	/* Number of bytes  */
645184Sek110237 	uint64_t	fs_wbytes;	/* Number of bytes  */
655184Sek110237 	uint64_t	fs_bytes;	/* Number of bytes  */
665184Sek110237 	uint64_t	fs_rcount;	/* Number of ops */
675184Sek110237 	uint64_t	fs_wcount;	/* Number of ops */
685184Sek110237 	hrtime_t	fs_stime;	/* Time stats for flow started */
695184Sek110237 	hrtime_t	fs_etime;	/* Time stats for flow ended */
705184Sek110237 	hrtime_t	fs_mstate[FLOW_MSTATES]; /* Microstate breakdown */
715184Sek110237 	hrtime_t	fs_syscpu;	/* System wide cpu, global only */
725184Sek110237 } flowstat_t;
735184Sek110237 
745184Sek110237 
755184Sek110237 #define	IS_FLOW_IOP(x) (x->fo_stats.fs_rcount + x->fo_stats.fs_wcount)
765184Sek110237 #define	STAT_IOPS(x)   ((x->fs_rcount) + (x->fs_wcount))
775184Sek110237 #define	IS_FLOW_ACTIVE(x) (x->fo_stats.fs_count)
785184Sek110237 #define	STAT_CPUTIME(x) (x->fs_cpu_op)
795184Sek110237 #define	STAT_OHEADTIME(x) (x->fs_cpu_ohead)
805184Sek110237 
815184Sek110237 #ifdef	__cplusplus
825184Sek110237 }
835184Sek110237 #endif
845184Sek110237 
855184Sek110237 #endif	/* _FB_STATS_H */
86