[Jifty-commit] r5462 - Runops-Trace/trunk

Jifty commits jifty-commit at lists.jifty.org
Tue May 13 11:13:57 EDT 2008


Author: nothingmuch
Date: Tue May 13 11:13:57 2008
New Revision: 5462

Added:
   Runops-Trace/trunk/bench.pl
Modified:
   Runops-Trace/trunk/   (props changed)

Log:
 r80561 at dhcp117:  nothingmuch | 2008-05-14 00:13:16 +0900
 benchmark


Added: Runops-Trace/trunk/bench.pl
==============================================================================
--- (empty file)
+++ Runops-Trace/trunk/bench.pl	Tue May 13 11:13:57 2008
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Benchmark qw(cmpthese countit timestr :hireswallclock);
+use Runops::Trace;
+
+our $obj = bless {};
+
+sub method { shift() . " ftw!!1one" }
+
+sub foo {
+	return [ @_[2,4] ];
+}
+
+sub waste_time {
+	our $j;
+	$j++;
+	foo(1 .. 5) for ( 1 .. 10 );
+	my $obj = bless({}, "main");
+	$obj->method(\"arg") for ( 1 .. 100 );
+};
+
+my %setup = (
+	normal => sub {
+		warn "not reg" if $INC{"Runops/Trace.pm"},
+	},
+	disabled => sub {
+		require Runops::Trace;
+		Runops::Trace::disable_tracing();
+	},
+	null_c_cb => sub {
+		require Runops::Trace;
+		Runops::Trace::clear_tracer();
+		Runops::Trace::enable_tracing();
+	},
+	mask => sub {
+		require Runops::Trace;
+		Runops::Trace::set_trace_threshold(0);
+		Runops::Trace::mask_all();
+		Runops::Trace::unmask_op(qw(entersub method_named));
+		Runops::Trace::set_tracer(sub { our $j++ });
+		Runops::Trace::enable_tracing();
+	},
+	threshold => sub {
+		require Runops::Trace;
+		Runops::Trace::clear_mask();
+		Runops::Trace::set_trace_threshold(5);
+		Runops::Trace::mask_op(qw(enteriter enterloop));
+		Runops::Trace::set_tracer(sub { our $j++ });
+		Runops::Trace::enable_tracing();
+	},
+	mask_and_threshold => sub {
+		next;
+		require Runops::Trace;
+		Runops::Trace::set_trace_threshold(5);
+		Runops::Trace::mask_all();
+		Runops::Trace::unmask_op(qw(entersub refgen method_named));
+		Runops::Trace::set_tracer(sub {our $j++ });
+		Runops::Trace::enable_tracing();
+	},
+	perl_hook => sub {
+		next;
+		require Runops::Trace;
+		Runops::Trace::clear_mask();
+		Runops::Trace::mask_op(qw(enteriter enterloop));
+		Runops::Trace::set_trace_threshold(0);
+		Runops::Trace::set_tracer(sub { our $j++ });
+		Runops::Trace::enable_tracing();
+	},
+);
+
+my %res;
+
+waste_time();
+
+foreach my $test qw(normal disabled null_c_cb mask threshold mask_and_threshold perl_hook) {
+	$setup{$test}->();
+	our $j = undef;
+
+	eval {
+		my $res = countit(1, \&waste_time);
+		$res{$test} = $res;
+		print "$test: " . timestr($res), "\n";
+	};
+
+	warn "test $test failed: $@" if $@;
+
+	$setup{disabled}->();
+}
+
+cmpthese(\%res);
+


More information about the Jifty-commit mailing list