Permalink
Browse files

Add a benchmark for re_emit(), which helps profile event cloning.

  • Loading branch information...
1 parent ec4a181 commit 8854a8610491ec04d9d654782993529abde32862 @rcaputo committed Jun 4, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 eg/bench-re-emit.pl
View
@@ -0,0 +1,35 @@
+#!/usr/bin/env perl
+
+# A program to benchmark and/or profile event creation and
+# destruction.
+#
+# Sample usage:
+#
+# perl -d:NYTProf bench-event.pl
+# nytprofhtml
+# open nytprof/index.html
+
+use warnings;
+use strict;
+
+{
+ package Thing;
+ use Moose;
+ extends 'Reflex::Base';
+
+ sub test {
+ my ($self, $event) = @_;
+
+ my $i = 100_000;
+ while ($i--) {
+ $self->re_emit($event, -name => "re_emitted");
+ }
+ }
+
+ __PACKAGE__->meta->make_immutable;
+}
+
+use Reflex::Event;
+my $t = Thing->new();
+
+$t->test( Reflex::Event->new( _name => "generic", _emitters => [ ] ) );

0 comments on commit 8854a86

Please sign in to comment.