#
# hotuser - sample on-CPU user-level functions and libraries.
# Written using Perl and DTrace (Solaris 10 03/05)
#
# This samples the on-CPU function at 1001 Hertz, for a simple yet
# effective user-level profiling tool for sampling exclusive function time.
# The output will identify which function is on the CPU the most - which
# is the hottest. See Notes/ALLexclusive_notes.txt for an explanation of
# exclusive time.
#
# $Id: hotuser 65 2007-10-04 11:09:40Z brendan $
#
# USAGE: hotuser [-hl] { -c command | -p PID }
#
# -h # help
# -l # match libraries, not functions
# -p PID # examine this PID
# -c command # run and examine this command
# eg,
# hotuser -p 81 # sample user functions from PID 81
# hotuser -lp 81 # sample user libraries from PID 81
# hotuser -p `pgrep -n Xorg` # sample Xorg
#
# FIELDS:
# FUNCTION Function name
# LIBRARY Library name
# COUNT Number of samples
# PCNT Percentage of total samples
#
# COPYRIGHT: Copyright (c) 2006 Brendan Gregg.
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# See the License for the specific language governing permissions
# and limitations under the License.
#
# CDDL HEADER END
#
# Author: Brendan Gregg [Sydney, Australia]
#
# 29-Jun-2006 Brendan Gregg Created this.
# 29-Jun-2006 " " Last update.
#
use strict;
#
# Command Line Arguments
#
my $args;
}
}
else {
}
#
# Cleanup on signals
#
#
# Declare DTrace script
#
my $dtrace = <<END;
/usr/sbin/dtrace -n '
#pragma D option quiet
profile:::profile-1001hz
/pid == \$target/
{
\@pc[arg1] = count();
}
dtrace:::END
{
printa("OUT: %A %\@d\\n", \@pc);
}
' '$args'
END
#
# Run DTrace, process output
#
my %Count;
my $total;
print "Sampling... Hit Ctrl-C to end.\n";
next if $line =~ /^\s*$/;
}
#
# Print final report
#
}
#
# Subroutines
#
sub cleanupsig {
}
sub usage {
exit 1;
}