File: benchmark

package info (click to toggle)
libobject-event-perl 1.230-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, buster, sid, trixie
  • size: 240 kB
  • sloc: perl: 1,099; makefile: 8
file content (38 lines) | stat: -rwxr-xr-x 508 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!perl

package foo;
use common::sense;

use base qw/Object::Event/;

sub new {
   my $this  = shift;
   my $class = ref($this) || $this;
   $class->SUPER::new (@_);
}

our $cnt;
sub test : event_cb { $cnt++ }

package main;
use common::sense;

use Benchmark qw/:all/;

my $f = foo->new;

for (1..10) {
   $f->reg_cb (test => sub {
      my ($f) = @_;
      $foo::cnt++;
   });
}

my $ev;

timethese (250000, {
   simple => sub { $f->event ('test') },
   method => sub { $f->test }
});

print "$foo::cnt\n";