| Filename | /Users/ap13/perl5/perlbrew/perls/perl-5.16.2/lib/5.16.2/darwin-2level/Opcode.pm |
| Statements | Executed 1806 statements in 5.36ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1 | 1 | 1 | 3.00ms | 3.64ms | Opcode::_init_optags |
| 1 | 1 | 1 | 327µs | 443µs | Opcode::BEGIN@29 |
| 316 | 2 | 1 | 224µs | 224µs | Opcode::CORE:match (opcode) |
| 19 | 1 | 1 | 94µs | 94µs | Opcode::opset (xsub) |
| 28 | 3 | 1 | 94µs | 94µs | Opcode::CORE:readline (opcode) |
| 1 | 1 | 1 | 82µs | 82µs | Opcode::opset_to_ops (xsub) |
| 101 | 1 | 1 | 73µs | 73µs | Opcode::CORE:subst (opcode) |
| 19 | 1 | 1 | 36µs | 36µs | Opcode::define_optag (xsub) |
| 1 | 1 | 1 | 26µs | 26µs | Opcode::BEGIN@3 |
| 1 | 1 | 1 | 24µs | 24µs | Opcode::CORE:close (opcode) |
| 1 | 1 | 1 | 19µs | 19µs | Opcode::BEGIN@15 |
| 1 | 1 | 1 | 15µs | 72µs | Opcode::BEGIN@11 |
| 1 | 1 | 1 | 13µs | 33µs | Opcode::BEGIN@5 |
| 1 | 1 | 1 | 9µs | 9µs | Opcode::BEGIN@13 |
| 1 | 1 | 1 | 8µs | 8µs | Opcode::full_opset (xsub) |
| 1 | 1 | 1 | 6µs | 6µs | Opcode::BEGIN@12 |
| 0 | 0 | 0 | 0s | 0s | Opcode::opdump |
| 0 | 0 | 0 | 0s | 0s | Opcode::ops_to_opset |
| 0 | 0 | 0 | 0s | 0s | Opcode::opset_to_hex |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Opcode; | ||||
| 2 | |||||
| 3 | 2 | 70µs | 1 | 26µs | # spent 26µs within Opcode::BEGIN@3 which was called:
# once (26µs+0s) by Safe::BEGIN@46 at line 3 # spent 26µs making 1 call to Opcode::BEGIN@3 |
| 4 | |||||
| 5 | 2 | 73µs | 2 | 53µs | # spent 33µs (13+20) within Opcode::BEGIN@5 which was called:
# once (13µs+20µs) by Safe::BEGIN@46 at line 5 # spent 33µs making 1 call to Opcode::BEGIN@5
# spent 20µs making 1 call to strict::import |
| 6 | |||||
| 7 | 1 | 700ns | our($VERSION, @ISA, @EXPORT_OK); | ||
| 8 | |||||
| 9 | 1 | 1µs | $VERSION = "1.23"; | ||
| 10 | |||||
| 11 | 2 | 36µs | 2 | 130µs | # spent 72µs (15+58) within Opcode::BEGIN@11 which was called:
# once (15µs+58µs) by Safe::BEGIN@46 at line 11 # spent 72µs making 1 call to Opcode::BEGIN@11
# spent 58µs making 1 call to Exporter::import |
| 12 | 2 | 31µs | 1 | 6µs | # spent 6µs within Opcode::BEGIN@12 which was called:
# once (6µs+0s) by Safe::BEGIN@46 at line 12 # spent 6µs making 1 call to Opcode::BEGIN@12 |
| 13 | 2 | 79µs | 1 | 9µs | # spent 9µs within Opcode::BEGIN@13 which was called:
# once (9µs+0s) by Safe::BEGIN@46 at line 13 # spent 9µs making 1 call to Opcode::BEGIN@13 |
| 14 | |||||
| 15 | # spent 19µs within Opcode::BEGIN@15 which was called:
# once (19µs+0s) by Safe::BEGIN@46 at line 24 | ||||
| 16 | 1 | 10µs | @ISA = qw(Exporter); | ||
| 17 | 1 | 10µs | @EXPORT_OK = qw( | ||
| 18 | opset ops_to_opset | ||||
| 19 | opset_to_ops opset_to_hex invert_opset | ||||
| 20 | empty_opset full_opset | ||||
| 21 | opdesc opcodes opmask define_optag | ||||
| 22 | opmask_add verify_opset opdump | ||||
| 23 | ); | ||||
| 24 | 1 | 68µs | 1 | 19µs | } # spent 19µs making 1 call to Opcode::BEGIN@15 |
| 25 | |||||
| 26 | sub opset (;@); | ||||
| 27 | sub opset_to_hex ($); | ||||
| 28 | sub opdump (;$); | ||||
| 29 | 2 | 911µs | 2 | 560µs | # spent 443µs (327+116) within Opcode::BEGIN@29 which was called:
# once (327µs+116µs) by Safe::BEGIN@46 at line 29 # spent 443µs making 1 call to Opcode::BEGIN@29
# spent 116µs making 1 call to subs::import |
| 30 | |||||
| 31 | 1 | 676µs | 1 | 661µs | XSLoader::load(); # spent 661µs making 1 call to XSLoader::load |
| 32 | |||||
| 33 | 1 | 3µs | 1 | 3.64ms | _init_optags(); # spent 3.64ms making 1 call to Opcode::_init_optags |
| 34 | |||||
| 35 | sub ops_to_opset { opset @_ } # alias for old name | ||||
| 36 | |||||
| 37 | sub opset_to_hex ($) { | ||||
| 38 | return "(invalid opset)" unless verify_opset($_[0]); | ||||
| 39 | unpack("h*",$_[0]); | ||||
| 40 | } | ||||
| 41 | |||||
| 42 | sub opdump (;$) { | ||||
| 43 | my $pat = shift; | ||||
| 44 | # handy utility: perl -MOpcode=opdump -e 'opdump File' | ||||
| 45 | foreach(opset_to_ops(full_opset)) { | ||||
| 46 | my $op = sprintf " %12s %s\n", $_, opdesc($_); | ||||
| 47 | next if defined $pat and $op !~ m/$pat/i; | ||||
| 48 | print $op; | ||||
| 49 | } | ||||
| 50 | } | ||||
| 51 | |||||
| - - | |||||
| 54 | # spent 3.64ms (3.00+635µs) within Opcode::_init_optags which was called:
# once (3.00ms+635µs) by Safe::BEGIN@46 at line 33 | ||||
| 55 | 1 | 400ns | my(%all, %seen); | ||
| 56 | 1 | 246µs | 2 | 90µs | @all{opset_to_ops(full_opset)} = (); # keys only # spent 82µs making 1 call to Opcode::opset_to_ops
# spent 8µs making 1 call to Opcode::full_opset |
| 57 | |||||
| 58 | 1 | 400ns | local($_); | ||
| 59 | 1 | 5µs | local($/) = "\n=cut"; # skip to optags definition section | ||
| 60 | 1 | 54µs | 1 | 45µs | <DATA>; # spent 45µs making 1 call to Opcode::CORE:readline |
| 61 | 1 | 2µs | $/ = "\n="; # now read in 'pod section' chunks | ||
| 62 | 1 | 38µs | 8 | 22µs | while(<DATA>) { # spent 22µs making 8 calls to Opcode::CORE:readline, avg 3µs/call |
| 63 | 26 | 125µs | 26 | 69µs | next unless m/^item\s+(:\w+)/; # spent 69µs making 26 calls to Opcode::CORE:match, avg 3µs/call |
| 64 | 19 | 31µs | my $tag = $1; | ||
| 65 | |||||
| 66 | # Split into lines, keep only indented lines | ||||
| 67 | 309 | 1.22ms | 290 | 155µs | my @lines = grep { m/^\s/ } split(/\n/); # spent 155µs making 290 calls to Opcode::CORE:match, avg 533ns/call |
| 68 | 120 | 300µs | 101 | 73µs | foreach (@lines) { s/--.*// } # delete comments # spent 73µs making 101 calls to Opcode::CORE:subst, avg 719ns/call |
| 69 | 120 | 222µs | my @ops = map { split ' ' } @lines; # get op words | ||
| 70 | |||||
| 71 | 19 | 14µs | foreach(@ops) { | ||
| 72 | 382 | 80µs | warn "$tag - $_ already tagged in $seen{$_}\n" if $seen{$_}; | ||
| 73 | 382 | 322µs | $seen{$_} = $tag; | ||
| 74 | 382 | 190µs | delete $all{$_}; | ||
| 75 | } | ||||
| 76 | # opset will croak on invalid names | ||||
| 77 | 19 | 397µs | 57 | 158µs | define_optag($tag, opset(@ops)); # spent 94µs making 19 calls to Opcode::opset, avg 5µs/call
# spent 36µs making 19 calls to Opcode::define_optag, avg 2µs/call
# spent 27µs making 19 calls to Opcode::CORE:readline, avg 1µs/call |
| 78 | } | ||||
| 79 | 1 | 34µs | 1 | 24µs | close(DATA); # spent 24µs making 1 call to Opcode::CORE:close |
| 80 | 1 | 89µs | warn "Untagged opnames: ".join(' ',keys %all)."\n" if %all; | ||
| 81 | } | ||||
| 82 | |||||
| 83 | |||||
| 84 | 1 | 18µs | 1; | ||
| 85 | |||||
| 86 | __DATA__ | ||||
# spent 24µs within Opcode::CORE:close which was called:
# once (24µs+0s) by Opcode::_init_optags at line 79 | |||||
sub Opcode::CORE:match; # opcode | |||||
sub Opcode::CORE:readline; # opcode | |||||
# spent 73µs within Opcode::CORE:subst which was called 101 times, avg 719ns/call:
# 101 times (73µs+0s) by Opcode::_init_optags at line 68, avg 719ns/call | |||||
# spent 36µs within Opcode::define_optag which was called 19 times, avg 2µs/call:
# 19 times (36µs+0s) by Opcode::_init_optags at line 77, avg 2µs/call | |||||
# spent 8µs within Opcode::full_opset which was called:
# once (8µs+0s) by Opcode::_init_optags at line 56 | |||||
# spent 94µs within Opcode::opset which was called 19 times, avg 5µs/call:
# 19 times (94µs+0s) by Opcode::_init_optags at line 77, avg 5µs/call | |||||
# spent 82µs within Opcode::opset_to_ops which was called:
# once (82µs+0s) by Opcode::_init_optags at line 56 |