| Filename | /home/ss5/perl5/perlbrew/perls/perl-5.22.0/lib/site_perl/5.22.0/x86_64-linux/Sereal/Decoder.pm |
| Statements | Executed 25 statements in 1.06ms |
| Calls | P | F | Exclusive Time |
Inclusive Time |
Subroutine |
|---|---|---|---|---|---|
| 1000 | 1 | 1 | 14.1ms | 14.1ms | Sereal::Decoder::decode_sereal (xsub) |
| 1 | 1 | 1 | 23µs | 23µs | Sereal::Decoder::BEGIN@2 |
| 1 | 1 | 1 | 21µs | 343µs | Sereal::Decoder::BEGIN@33 |
| 1 | 1 | 1 | 10µs | 14µs | Sereal::Decoder::BEGIN@3 |
| 1 | 1 | 1 | 8µs | 19µs | Sereal::Decoder::BEGIN@4 |
| 1 | 1 | 1 | 8µs | 16µs | Sereal::Decoder::BEGIN@16 |
| 1 | 1 | 1 | 7µs | 53µs | Sereal::Decoder::BEGIN@5 |
| 1 | 1 | 1 | 5µs | 5µs | Sereal::Decoder::BEGIN@6 |
| 1 | 1 | 1 | 4µs | 4µs | Sereal::Decoder::CORE:subst (opcode) |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::CLONE_SKIP |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::__ANON__[:135] |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::_test_compat |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::decode_from_file |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::flag_names |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::flag_names_static |
| 0 | 0 | 0 | 0s | 0s | Sereal::Decoder::flag_names_volatile |
| Line | State ments |
Time on line |
Calls | Time in subs |
Code |
|---|---|---|---|---|---|
| 1 | package Sereal::Decoder; | ||||
| 2 | 2 | 53µs | 1 | 23µs | # spent 23µs within Sereal::Decoder::BEGIN@2 which was called:
# once (23µs+0s) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 2 # spent 23µs making 1 call to Sereal::Decoder::BEGIN@2 |
| 3 | 2 | 27µs | 2 | 19µs | # spent 14µs (10+4) within Sereal::Decoder::BEGIN@3 which was called:
# once (10µs+4µs) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 3 # spent 14µs making 1 call to Sereal::Decoder::BEGIN@3
# spent 4µs making 1 call to strict::import |
| 4 | 2 | 24µs | 2 | 30µs | # spent 19µs (8+11) within Sereal::Decoder::BEGIN@4 which was called:
# once (8µs+11µs) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 4 # spent 19µs making 1 call to Sereal::Decoder::BEGIN@4
# spent 11µs making 1 call to warnings::import |
| 5 | 2 | 22µs | 2 | 99µs | # spent 53µs (7+46) within Sereal::Decoder::BEGIN@5 which was called:
# once (7µs+46µs) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 5 # spent 53µs making 1 call to Sereal::Decoder::BEGIN@5
# spent 46µs making 1 call to Exporter::import |
| 6 | 2 | 134µs | 1 | 5µs | # spent 5µs within Sereal::Decoder::BEGIN@6 which was called:
# once (5µs+0s) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 6 # spent 5µs making 1 call to Sereal::Decoder::BEGIN@6 |
| 7 | |||||
| 8 | 1 | 400ns | our $VERSION = '3.014'; # Don't forget to update the TestCompat set for testing against installed encoders! | ||
| 9 | 2 | 13µs | our $XS_VERSION = $VERSION; $VERSION= eval $VERSION; # spent 2µs executing statements in string eval | ||
| 10 | |||||
| 11 | # not for public consumption, just for testing. | ||||
| 12 | 1 | 10µs | 1 | 4µs | (my $num_version = $VERSION) =~ s/_//; # spent 4µs making 1 call to Sereal::Decoder::CORE:subst |
| 13 | 1 | 20µs | my $TestCompat = [ map sprintf("%.2f", $_/100), reverse( 300 .. int($num_version * 100) ) ]; # compat with 3.00 to ... | ||
| 14 | sub _test_compat { return(@$TestCompat, $VERSION) } | ||||
| 15 | |||||
| 16 | 2 | 205µs | 2 | 24µs | # spent 16µs (8+8) within Sereal::Decoder::BEGIN@16 which was called:
# once (8µs+8µs) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 16 # spent 16µs making 1 call to Sereal::Decoder::BEGIN@16
# spent 8µs making 1 call to Exporter::import |
| 17 | 1 | 1µs | our @EXPORT_OK = qw( | ||
| 18 | decode_sereal looks_like_sereal decode_sereal_with_header_data | ||||
| 19 | scalar_looks_like_sereal | ||||
| 20 | sereal_decode_with_object sereal_decode_with_header_with_object | ||||
| 21 | sereal_decode_only_header_with_object | ||||
| 22 | sereal_decode_only_header_with_offset_with_object | ||||
| 23 | sereal_decode_with_header_and_offset_with_object | ||||
| 24 | sereal_decode_with_offset_with_object | ||||
| 25 | ); | ||||
| 26 | 1 | 2µs | our %EXPORT_TAGS = (all => \@EXPORT_OK); | ||
| 27 | # export by default if run from command line | ||||
| 28 | 1 | 2µs | our @EXPORT = ((caller())[1] eq '-e' ? @EXPORT_OK : ()); | ||
| 29 | |||||
| 30 | sub CLONE_SKIP { 1 } | ||||
| 31 | 1 | 240µs | 1 | 232µs | XSLoader::load('Sereal::Decoder', $XS_VERSION); # spent 232µs making 1 call to XSLoader::load |
| 32 | use constant #begin generated | ||||
| 33 | # spent 343µs (21+322) within Sereal::Decoder::BEGIN@33 which was called:
# once (21µs+322µs) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 111 | ||||
| 34 | 1 | 19µs | 1 | 322µs | 'SRL_F_DECODER_ALIAS_CHECK_FLAGS' => 28672, # spent 322µs making 1 call to constant::import |
| 35 | 'SRL_F_DECODER_ALIAS_SMALLINT' => 4096, | ||||
| 36 | 'SRL_F_DECODER_ALIAS_VARINT' => 8192, | ||||
| 37 | 'SRL_F_DECODER_DECOMPRESS_SNAPPY' => 8, | ||||
| 38 | 'SRL_F_DECODER_DECOMPRESS_ZLIB' => 16, | ||||
| 39 | 'SRL_F_DECODER_DESTRUCTIVE_INCREMENTAL' => 1024, | ||||
| 40 | 'SRL_F_DECODER_DIRTY' => 2, | ||||
| 41 | 'SRL_F_DECODER_NEEDS_FINALIZE' => 4, | ||||
| 42 | 'SRL_F_DECODER_NO_BLESS_OBJECTS' => 512, | ||||
| 43 | 'SRL_F_DECODER_PROTOCOL_V1' => 2048, | ||||
| 44 | 'SRL_F_DECODER_READONLY_FLAGS' => 98304, | ||||
| 45 | 'SRL_F_DECODER_REFUSE_OBJECTS' => 128, | ||||
| 46 | 'SRL_F_DECODER_REFUSE_SNAPPY' => 32, | ||||
| 47 | 'SRL_F_DECODER_REFUSE_ZLIB' => 64, | ||||
| 48 | 'SRL_F_DECODER_REUSE' => 1, | ||||
| 49 | 'SRL_F_DECODER_SET_READONLY' => 32768, | ||||
| 50 | 'SRL_F_DECODER_SET_READONLY_SCALARS' => 65536, | ||||
| 51 | 'SRL_F_DECODER_USE_UNDEF' => 16384, | ||||
| 52 | 'SRL_F_DECODER_VALIDATE_UTF8' => 256, | ||||
| 53 | 'SRL_F_DECODER_VOLATILE_FLAGS' => 2078, | ||||
| 54 | '_FLAG_NAME' => [ | ||||
| 55 | 'REUSE', | ||||
| 56 | 'DIRTY', | ||||
| 57 | 'NEEDS_FINALIZE', | ||||
| 58 | 'DECOMPRESS_SNAPPY', | ||||
| 59 | 'DECOMPRESS_ZLIB', | ||||
| 60 | 'REFUSE_SNAPPY', | ||||
| 61 | 'REFUSE_ZLIB', | ||||
| 62 | 'REFUSE_OBJECTS', | ||||
| 63 | 'VALIDATE_UTF8', | ||||
| 64 | 'NO_BLESS_OBJECTS', | ||||
| 65 | 'DESTRUCTIVE_INCREMENTAL', | ||||
| 66 | 'PROTOCOL_V1', | ||||
| 67 | 'ALIAS_SMALLINT', | ||||
| 68 | 'ALIAS_VARINT', | ||||
| 69 | 'USE_UNDEF', | ||||
| 70 | 'SET_READONLY', | ||||
| 71 | 'SET_READONLY_SCALARS' | ||||
| 72 | ], | ||||
| 73 | '_FLAG_NAME_STATIC' => [ | ||||
| 74 | 'REUSE', | ||||
| 75 | undef, | ||||
| 76 | undef, | ||||
| 77 | undef, | ||||
| 78 | undef, | ||||
| 79 | 'REFUSE_SNAPPY', | ||||
| 80 | 'REFUSE_ZLIB', | ||||
| 81 | 'REFUSE_OBJECTS', | ||||
| 82 | 'VALIDATE_UTF8', | ||||
| 83 | 'NO_BLESS_OBJECTS', | ||||
| 84 | 'DESTRUCTIVE_INCREMENTAL', | ||||
| 85 | undef, | ||||
| 86 | 'ALIAS_SMALLINT', | ||||
| 87 | 'ALIAS_VARINT', | ||||
| 88 | 'USE_UNDEF', | ||||
| 89 | 'SET_READONLY', | ||||
| 90 | 'SET_READONLY_SCALARS' | ||||
| 91 | ], | ||||
| 92 | '_FLAG_NAME_VOLATILE' => [ | ||||
| 93 | undef, | ||||
| 94 | 'DIRTY', | ||||
| 95 | 'NEEDS_FINALIZE', | ||||
| 96 | 'DECOMPRESS_SNAPPY', | ||||
| 97 | 'DECOMPRESS_ZLIB', | ||||
| 98 | undef, | ||||
| 99 | undef, | ||||
| 100 | undef, | ||||
| 101 | undef, | ||||
| 102 | undef, | ||||
| 103 | undef, | ||||
| 104 | 'PROTOCOL_V1', | ||||
| 105 | undef, | ||||
| 106 | undef, | ||||
| 107 | undef, | ||||
| 108 | undef, | ||||
| 109 | undef | ||||
| 110 | ] | ||||
| 111 | 1 | 271µs | 1 | 343µs | }; #end generated # spent 343µs making 1 call to Sereal::Decoder::BEGIN@33 |
| 112 | |||||
| 113 | sub decode_from_file { | ||||
| 114 | my ($self, $file, )= @_; # pos 3 is "target var" if one is provided | ||||
| 115 | open my $fh, "<", $file | ||||
| 116 | or die "Failed to open '$file' for read: $!"; | ||||
| 117 | my $buf= do{ local $/; <> }; | ||||
| 118 | close $fh | ||||
| 119 | or die "Failed to close '$file': $!"; | ||||
| 120 | if (wantarray && ($self->flags & SRL_F_DECODER_DESTRUCTIVE_INCREMENTAL)) { | ||||
| 121 | my @ret; | ||||
| 122 | while (length $buf) { | ||||
| 123 | push @ret, $self->decode($buf); | ||||
| 124 | } | ||||
| 125 | return @ret; | ||||
| 126 | } | ||||
| 127 | return $self->decode($file, $_[2]); | ||||
| 128 | } | ||||
| 129 | |||||
| 130 | my $flags= sub { | ||||
| 131 | my ($int, $ary)= @_; | ||||
| 132 | return map { | ||||
| 133 | ($ary->[$_] and $int & (1 << $_)) ? $ary->[$_] : () | ||||
| 134 | } (0..$#$ary); | ||||
| 135 | 1 | 2µs | }; | ||
| 136 | |||||
| 137 | sub flag_names { | ||||
| 138 | my ($self, $val)= @_; | ||||
| 139 | return $flags->(defined $val ? $val : $self->flags, _FLAG_NAME); | ||||
| 140 | } | ||||
| 141 | |||||
| 142 | sub flag_names_volatile { | ||||
| 143 | my ($self, $val)= @_; | ||||
| 144 | return $flags->($val // $self->flags, _FLAG_NAME_VOLATILE); | ||||
| 145 | } | ||||
| 146 | |||||
| 147 | sub flag_names_static { | ||||
| 148 | my ($self, $val)= @_; | ||||
| 149 | return $flags->($val // $self->flags, _FLAG_NAME_STATIC); | ||||
| 150 | } | ||||
| 151 | |||||
| 152 | 1 | 10µs | 1; | ||
| 153 | |||||
| 154 | __END__ | ||||
# spent 4µs within Sereal::Decoder::CORE:subst which was called:
# once (4µs+0s) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 12 | |||||
# spent 14.1ms within Sereal::Decoder::decode_sereal which was called 1000 times, avg 14µs/call:
# 1000 times (14.1ms+0s) by BenchmarkAnything::Storage::Backend::SQL::process_queued_multi_benchmark at line 437 of BenchmarkAnything/Storage/Backend/SQL.pm, avg 14µs/call |