3 * cswstat.d - context switch time stat.
4 * Uses DTrace (Solaris 10 03/05)
6 * This prints a context switch count and consumed time for context
7 * switching every second.
9 * $Id: cswstat.d 15 2007-09-11 09:09:25Z brendan $
15 * NUM Number of context switches
16 * CSWTIME(us) Time consumed context switching, us
17 * AVGTIME(us) Average context switch time, us
19 * THANKS: Toomas Soome
21 * COPYRIGHT: Copyright (c) 2005 Brendan Gregg.
25 * The contents of this file are subject to the terms of the
26 * Common Development and Distribution License, Version 1.0 only
27 * (the "License"). You may not use this file except in compliance
30 * You can obtain a copy of the license at Docs/cddl1.txt
31 * or http://www.opensolaris.org/os/licensing.
32 * See the License for the specific language governing permissions
33 * and limitations under the License.
37 * 17-May-2005 Brendan Gregg Created this.
38 * 03-Nov-2005 " " Last update.
41 #pragma D option quiet
46 printf("%-20s %8s %12s %12s\n", "TIME", "NUM", "CSWTIME(us)",
56 start[cpu] = timestamp;
63 times += timestamp - start[cpu];
70 printf("%20Y %8d %12d %12d\n", walltimestamp, num, times/1000,
71 num == 0 ? 0 : times/(1000 * num));