[Jifty-commit] r5434 - in Runops-Trace/trunk: . lib/Runops
Jifty commits
jifty-commit at lists.jifty.org
Sat May 10 09:59:11 EDT 2008
Author: nothingmuch
Date: Sat May 10 09:59:11 2008
New Revision: 5434
Modified:
Runops-Trace/trunk/Trace.xs
Runops-Trace/trunk/lib/Runops/Trace.pm
Runops-Trace/trunk/t/06counters.t
Log:
get_tracer, more docs
Modified: Runops-Trace/trunk/Trace.xs
==============================================================================
--- Runops-Trace/trunk/Trace.xs (original)
+++ Runops-Trace/trunk/Trace.xs Sat May 10 09:59:11 2008
@@ -290,9 +290,7 @@
void
Runops_Trace_clear_perl_hook(pTHX) {
- if ( Runops_Trace_perl_hook != (SV*)NULL ) {
- SvSetSV(Runops_Trace_perl_hook, &PL_sv_undef );
- }
+ SvSetSV(Runops_Trace_perl_hook, &PL_sv_undef );
}
void
@@ -316,12 +314,7 @@
Runops_Trace_load_B(aTHX);
/* Initialize/set the tracing function */
- if ( Runops_Trace_perl_hook == (SV*)NULL ) {
- Runops_Trace_perl_hook = newSVsv( tracer_rv );
- }
- else {
- SvSetSV( Runops_Trace_perl_hook, tracer_rv );
- }
+ SvSetSV( Runops_Trace_perl_hook, tracer_rv );
Runops_Trace_set_hook(Runops_Trace_perl);
}
@@ -345,9 +338,10 @@
Runops_Trace_clear_hook();
Runops_Trace_old_runops = PL_runops;
PL_runops = runops_trace;
+ Runops_Trace_perl_hook = newSVsv( &PL_sv_undef );
HV *
-counters()
+get_op_counters()
CODE:
{
if ( !Runops_Trace_op_counters )
@@ -404,6 +398,15 @@
Runops_Trace_set_perl_hook(aTHX_ hook);
}
+SV *
+get_tracer()
+ CODE:
+{
+ RETVAL = Runops_Trace_perl_hook;
+}
+ OUTPUT:
+ RETVAL
+
void
clear_tracer()
CODE:
Modified: Runops-Trace/trunk/lib/Runops/Trace.pm
==============================================================================
--- Runops-Trace/trunk/lib/Runops/Trace.pm (original)
+++ Runops-Trace/trunk/lib/Runops/Trace.pm Sat May 10 09:59:11 2008
@@ -14,9 +14,9 @@
our @EXPORT_OK = qw(
trace_code checksum_code_path trace
- set_tracer enable_tracing disable_tracing tracing_enabled
+ set_tracer get_tracer clear_tracer enable_tracing disable_tracing tracing_enabled
- set_trace_threshold get_trace_threshold counters
+ set_trace_threshold get_trace_threshold get_op_counters
);
our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK );
@@ -123,6 +123,46 @@
If called in list context will return the list of L<B::OP> objects.
+=item set_tracer( FUNCTION )
+
+This sets the tracer function globally.
+
+C<trace> uses this.
+
+=item CODEREF = get_tracer()
+
+Get the tracing sub (if any).
+
+=item clear_tracer()
+
+Remove the tracing sub.
+
+=item enable_tracing()
+
+=item disable_tracing()
+
+Controls tracing globally.
+
+=item tracing_enabled()
+
+Returns whether or not tracing is enabled.
+
+=item set_trace_threshold( INT )
+
+=item INT = get_trace_threshold()
+
+=item HASHREF = get_op_counters()
+
+If set to a nonzero value then every opcode will be counted in a hash
+(C<get_op_counters> returns that hash).
+
+The trace function would only be triggerred after the counter for that opcode
+has reached a certain number.
+
+This is useful for when you only want to trace a certain hot path.
+
+=item
+
=back
=head1 PERL HACKS COMPATIBILITY
Modified: Runops-Trace/trunk/t/06counters.t
==============================================================================
--- Runops-Trace/trunk/t/06counters.t (original)
+++ Runops-Trace/trunk/t/06counters.t Sat May 10 09:59:11 2008
@@ -10,7 +10,7 @@
Runops::Trace::set_tracer(sub {});
-is_deeply( Runops::Trace::counters(), {}, "no counters yet" );
+is_deeply( Runops::Trace::get_op_counters(), {}, "no counters yet" );
Runops::Trace::set_trace_threshold(3);
@@ -25,4 +25,4 @@
is( $i, 10, "loop ran correctly" );
-ok( scalar(keys %{ Runops::Trace::counters() }), "counted something now" );
+ok( scalar(keys %{ Runops::Trace::get_op_counters() }), "counted something now" );
More information about the Jifty-commit
mailing list