1N/A# hotuser - sample on-CPU user-level functions and libraries. 1N/A# Written using Perl and DTrace (Solaris 10 03/05) 1N/A# This samples the on-CPU function at 1001 Hertz, for a simple yet 1N/A# effective user-level profiling tool for sampling exclusive function time. 1N/A# The output will identify which function is on the CPU the most - which 1N/A# $Id: hotuser 65 2007-10-04 11:09:40Z brendan $ 1N/A# USAGE: hotuser [-hl] { -c command | -p PID } 1N/A# -l # match libraries, not functions 1N/A# -p PID # examine this PID 1N/A# -c command # run and examine this command 1N/A# hotuser -p 81 # sample user functions from PID 81 1N/A# hotuser -lp 81 # sample user libraries from PID 81 1N/A# hotuser -p `pgrep -n Xorg` # sample Xorg 1N/A# FUNCTION Function name 1N/A# LIBRARY Library name 1N/A# COUNT Number of samples 1N/A# PCNT Percentage of total samples 1N/A# COPYRIGHT: Copyright (c) 2006 Brendan Gregg. 1N/A# The contents of this file are subject to the terms of the 1N/A# Common Development and Distribution License, Version 1.0 only 1N/A# (the "License"). You may not use this file except in compliance 1N/A# See the License for the specific language governing permissions 1N/A# and limitations under the License. 1N/A# Author: Brendan Gregg [Sydney, Australia] 1N/A# 29-Jun-2006 Brendan Gregg Created this. 1N/A# 29-Jun-2006 " " Last update. 1N/A# Command Line Arguments 1N/A# Declare DTrace script 1N/A/usr/sbin/dtrace -n ' 1N/A #pragma D option quiet 1N/A profile:::profile-1001hz 1N/A \@pc[arg1] = count(); 1N/A printa("OUT: %A %\@d\\n", \@pc); 1N/A# Run DTrace, process output 1N/Aprint "Sampling... Hit Ctrl-C to end.\n";
1N/Aprintf "\n%-52s %8s %6s\n",
$libs ?
"LIBRARY" :
"FUNCTION",
"COUNT",
"PCNT";
1N/A print STDERR "USAGE: hotuser [-hl] { -c command | -p PID }\n"; 1N/A print STDERR " hotuser -p 81 # sample user funcs for PID 81\n"; 1N/A print STDERR " hotuser -lp 81 # sample user libs for PID 81\n";