Permalink
Browse files

Renamed POE::Resource::Performance to POE::Resource::Statistics. The

new form follows the POE::Resource::{plural thingy here} naming
convention, and it opens the door for gathering statistics that may
have nothing to do with performance.  TRACE_PERFORMANCE has also been
renamed TRACE_STATISTICS.
  • Loading branch information...
rcaputo committed Jan 21, 2004
1 parent 6f2eca9 commit 4a691fdf7c8ce6b1120a1adab9ec140763219f83
View
@@ -46,10 +46,10 @@ POE/Resource/Aliases.pm
POE/Resource/Events.pm
POE/Resource/Extrefs.pm
POE/Resource/FileHandles.pm
-POE/Resource/Performance.pm
POE/Resource/SIDs.pm
POE/Resource/Sessions.pm
POE/Resource/Signals.pm
+POE/Resource/Statistics.pm
POE/Resources.pm
POE/Session.pm
POE/Wheel.pm
View
@@ -143,7 +143,7 @@ sub EN_SCPOLL () { '_sigchld_poll' }
sub EN_SIGNAL () { '_signal' }
sub EN_START () { '_start' }
sub EN_STOP () { '_stop' }
-sub EN_PERF () { '_perftick' }
+sub EN_STAT () { '_stat_tick' }
# These are POE's event classes (types). They often shadow the event
# names themselves, but they can encompass a large group of events.
@@ -162,10 +162,10 @@ sub ET_CHILD () { 0x0080 } # _child
sub ET_SCPOLL () { 0x0100 } # _sigchild_poll
sub ET_ALARM () { 0x0200 } # Alarm events.
sub ET_SELECT () { 0x0400 } # File activity events.
-sub ET_PERF () { 0x0800 } # Performance polling
+sub ET_STAT () { 0x0800 } # Statistics gathering
# A mask for all events generated by/for users.
-sub ET_MASK_USER () { ~(ET_GC | ET_SCPOLL | ET_PERF) }
+sub ET_MASK_USER () { ~(ET_GC | ET_SCPOLL | ET_STAT) }
# Temporary signal subtypes, used during signal dispatch semantics
# deprecation and reformation.
@@ -179,7 +179,7 @@ sub ET_SIGNAL_COMPATIBLE () { 0x1000 } # Backward-compatible semantics.
my %poes_own_events =
( EN_CHILD , 1, EN_GC , 1, EN_PARENT , 1, EN_SCPOLL , 1,
- EN_SIGNAL , 1, EN_START , 1, EN_STOP , 1, EN_PERF, 1,
+ EN_SIGNAL , 1, EN_START , 1, EN_STOP , 1, EN_STAT, 1,
);
# These are ways a child may come or go.
@@ -270,7 +270,7 @@ BEGIN {
defined &TRACE_DEFAULT or eval "sub TRACE_DEFAULT () { 0 }";
define_trace qw(
- EVENTS FILES PERFORMANCE PROFILE REFCNT RETVALS SESSIONS SIGNALS
+ EVENTS FILES PROFILE REFCNT RETVALS SESSIONS SIGNALS STATISTICS
);
# See the notes for TRACE_DEFAULT, except read ASSERT and assert
@@ -281,7 +281,7 @@ BEGIN {
define_assert qw(DATA EVENTS FILES RETVALS USAGE);
}
-# This is a second BEGIN block so TRACE_PERFORMANCE may be defined
+# This is a second BEGIN block so TRACE_STATISTICS may be defined
# already.
BEGIN {
@@ -653,11 +653,11 @@ sub new {
# Initialize subsystems. The order is important.
# We need events before sessions, and the kernel's session before
- # it can start polling for signals. Performance gathering
- # requires a polling event as well, so it goes late.
+ # it can start polling for signals. Statistics gathering requires
+ # a polling event as well, so it goes late.
$self->_data_ev_initialize($kr_queue);
$self->_initialize_kernel_session();
- $self->_data_perf_initialize() if TRACE_PERFORMANCE;
+ $self->_data_stat_initialize() if TRACE_STATISTICS;
$self->_data_sig_initialize();
# These other subsystems don't have strange interactions.
@@ -699,7 +699,7 @@ sub _dispatch_event {
my $local_event = $event;
- $self->_perf_profile($event) if TRACE_PROFILE;
+ $self->_stat_profile($event) if TRACE_PROFILE;
# Pre-dispatch processing.
@@ -846,7 +846,7 @@ sub _dispatch_event {
# Dispatch the event, at long last.
my $before;
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
$before = time();
}
my $return;
@@ -859,12 +859,12 @@ sub _dispatch_event {
$session->_invoke_state($source_session, $event, $etc, $file, $line);
}
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
my $after = time();
my $elapsed = $after - $before;
if ($type & ET_MASK_USER) {
- $self->_data_perf_add('user_seconds', $elapsed);
- $self->_data_perf_add('user_events', 1);
+ $self->_data_stat_add('user_seconds', $elapsed);
+ $self->_data_stat_add('user_events', 1);
}
}
@@ -978,7 +978,7 @@ sub finalize_kernel {
$self->_data_handle_finalize();
$self->_data_ev_finalize();
$self->_data_ses_finalize();
- $self->_data_perf_finalize() if TRACE_PROFILE or TRACE_PERFORMANCE;
+ $self->_data_stat_finalize() if TRACE_PROFILE or TRACE_STATISTICS;
}
sub run_one_timeslice {
@@ -1168,8 +1168,8 @@ sub _invoke_state {
}
}
- elsif ($event eq EN_PERF) {
- $self->_data_perf_tick();
+ elsif ($event eq EN_STAT) {
+ $self->_data_stat_tick();
}
return 0;
@@ -1190,7 +1190,7 @@ sub session_alloc {
if ($kr_run_warning & KR_RUN_DONE) {
$kr_run_warning &= ~KR_RUN_DONE;
$self->_initialize_kernel_session();
- $self->_data_perf_initialize() if TRACE_PERFORMANCE;
+ $self->_data_stat_initialize() if TRACE_STATISTICS;
$self->_data_sig_initialize();
}
@@ -3655,16 +3655,18 @@ elsewhere, set TRACE_FILENAME to the file where they should go.
TRACE_FILES enables or disables messages that tell how files are being
processed within POE::Kernel and the event loop bridges.
-=item TRACE_PERFORMANCE
+=item TRACE_STATISTICS
B<This feature is experimental. No doubt it will change.>
-This keeps track of how much time is spent processing event callbacks,
-time spent in POE, and time spent waiting for an event. A report is
-displayed just before run() returns, or the data can be retrieved at
-any time using perf_getdata().
+TRACE_STATISTICS enables runtime gathering and reporting of various
+performance metrics within a POE program. Some statistics include how
+much time is spent processing event callbacks, time spent in POE's
+dispatcher, and the time spent waiting for an event. A report is
+displayed just before run() returns, and the data can be retrieved at
+any time using stat_getdata().
-perf_getdata() returns a hashref of various statistics and their
+stat_getdata() returns a hashref of various statistics and their
values. The statistics are calculated using a sliding window and vary
over time as a program runs.
@@ -3673,7 +3675,7 @@ over time as a program runs.
TRACE_PROFILE switches on event profiling. This causes the Kernel to
keep a count of every event it dispatches. A report of the events and
their frequencies is displayed just before run() returns, or at
-any time via perf_show_profile().
+any time via stat_show_profile().
=item TRACE_REFCNT
View
@@ -208,12 +208,12 @@ my $last_time = time();
sub _loop_event_callback {
my $self = $poe_kernel;
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
# TODO - I'm pretty sure the startup time will count as an unfair
# amout of idleness.
#
# TODO - Introducing many new time() syscalls. Bleah.
- $self->_data_perf_add('idle_seconds', time() - $last_time);
+ $self->_data_stat_add('idle_seconds', time() - $last_time);
}
$self->_data_ev_dispatch_due();
@@ -242,7 +242,7 @@ sub _loop_event_callback {
}
# Transfering control back to Event; this is idle time.
- $last_time = time() if TRACE_PERFORMANCE;
+ $last_time = time() if TRACE_STATISTICS;
}
# Event filehandle callback to dispatch selects.
View
@@ -216,12 +216,12 @@ my $last_time = time();
sub _loop_event_callback {
my $self = $poe_kernel;
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
# TODO - I'm pretty sure the startup time will count as an unfair
# amout of idleness.
#
# TODO - Introducing many new time() syscalls. Bleah.
- $self->_data_perf_add('idle_seconds', time() - $last_time);
+ $self->_data_stat_add('idle_seconds', time() - $last_time);
}
$self->_data_ev_dispatch_due();
@@ -236,7 +236,7 @@ sub _loop_event_callback {
}
# And back to Gtk, so we're in idle mode.
- $last_time = time() if TRACE_PERFORMANCE;
+ $last_time = time() if TRACE_STATISTICS;
# Return false to stop.
return 0;
View
@@ -343,8 +343,8 @@ sub loop_do_timeslice {
}
}
- if (TRACE_PERFORMANCE) {
- $self->_data_perf_add('idle_seconds', time() - $now);
+ if (TRACE_STATISTICS) {
+ $self->_data_stat_add('idle_seconds', time() - $now);
}
# Dispatch whatever events are due.
View
@@ -312,13 +312,13 @@ sub loop_do_timeslice {
}
}
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
# TODO - I think $now is too far ahead of select() and this call
# is too far afterwards. Unless "idle" seconds means also the
# time POE::Kernel spends scheduling things. Sent a note to Nick
# Williams asking for clarification on the definitions of various
# statistics.
- $self->_data_perf_add('idle_seconds', time() - $now);
+ $self->_data_stat_add('idle_seconds', time() - $now);
}
# Dispatch whatever events are due.
View
@@ -78,12 +78,12 @@ sub loop_pause_time_watcher {
my $last_time = time();
sub _loop_event_callback {
- if (TRACE_PERFORMANCE) {
+ if (TRACE_STATISTICS) {
# TODO - I'm pretty sure the startup time will count as an unfair
# amout of idleness.
#
# TODO - Introducing many new time() syscalls. Bleah.
- $poe_kernel->_data_perf_add('idle_seconds', time() - $last_time);
+ $poe_kernel->_data_stat_add('idle_seconds', time() - $last_time);
}
$poe_kernel->_data_ev_dispatch_due();
@@ -143,7 +143,7 @@ sub _loop_event_callback {
}
# And back to Tk, so we're in idle mode.
- $last_time = time() if TRACE_PERFORMANCE;
+ $last_time = time() if TRACE_STATISTICS;
}
#------------------------------------------------------------------------------
@@ -238,8 +238,8 @@ sub _data_ev_dispatch_due {
}
if ($time < $now) {
- $self->_data_perf_add('blocked', 1);
- $self->_data_perf_add('blocked_seconds', $now - $time);
+ $self->_data_stat_add('blocked', 1);
+ $self->_data_stat_add('blocked_seconds', $now - $time);
}
$self->_data_ev_refcount_dec($event->[EV_SOURCE], $event->[EV_SESSION]);
Oops, something went wrong.

0 comments on commit 4a691fd

Please sign in to comment.