← Index
NYTProf Performance Profile   « line view »
For ../prof.pl
  Run on Thu Dec 15 15:23:56 2022
Reported on Thu Dec 15 15:27:01 2022

Filename/Users/ether/perl5/perlbrew/perls/36.0/lib/5.36.0/constant.pm
StatementsExecuted 5328 statements in 4.77ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
160160292.90ms3.71msconstant::::importconstant::import
19111234µs234µsconstant::::CORE:substconstant::CORE:subst (opcode)
19111230µs230µsconstant::::CORE:matchconstant::CORE:match (opcode)
19111177µs177µsconstant::::CORE:regcompconstant::CORE:regcomp (opcode)
11142µs62µsconstant::::BEGIN@4constant::BEGIN@4
11123µs23µsconstant::::BEGIN@2constant::BEGIN@2
1117µs8µsconstant::::BEGIN@24constant::BEGIN@24
1116µs12µsconstant::::BEGIN@40constant::BEGIN@40
1115µs8µsconstant::::BEGIN@3constant::BEGIN@3
1115µs7µsconstant::::BEGIN@65constant::BEGIN@65
1115µs8µsconstant::::BEGIN@90constant::BEGIN@90
3315µs5µsconstant::::CORE:qrconstant::CORE:qr (opcode)
1113µs5µsconstant::::BEGIN@141constant::BEGIN@141
0000s0sconstant::::__ANON__[:174]constant::__ANON__[:174]
0000s0sconstant::::__ANON__[:190]constant::__ANON__[:190]
0000s0sconstant::::__ANON__[:192]constant::__ANON__[:192]
0000s0sconstant::::__ANON__[:41]constant::__ANON__[:41]
0000s0sconstant::::__ANON__[:42]constant::__ANON__[:42]
0000s0sconstant::::__ANON__[:43]constant::__ANON__[:43]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package constant;
2233µs123µs
# spent 23µs within constant::BEGIN@2 which was called: # once (23µs+0s) by Feature::Compat::Try::BEGIN@13 at line 2
use 5.008;
# spent 23µs making 1 call to constant::BEGIN@2
3221µs211µs
# spent 8µs (5+3) within constant::BEGIN@3 which was called: # once (5µs+3µs) by Feature::Compat::Try::BEGIN@13 at line 3
use strict;
# spent 8µs making 1 call to constant::BEGIN@3 # spent 3µs making 1 call to strict::import
42215µs282µs
# spent 62µs (42+20) within constant::BEGIN@4 which was called: # once (42µs+20µs) by Feature::Compat::Try::BEGIN@13 at line 4
use warnings::register;
# spent 62µs making 1 call to constant::BEGIN@4 # spent 20µs making 1 call to warnings::register::import
5
610sour $VERSION = '1.33';
7our %declared;
8
9#=======================================================================
10
11# Some names are evil choices.
1215µsmy %keywords = map +($_, 1), qw{ BEGIN INIT CHECK END DESTROY AUTOLOAD };
1311µs$keywords{UNITCHECK}++ if $] > 5.009;
14
1512µsmy %forced_into_main = map +($_, 1),
16 qw{ STDIN STDOUT STDERR ARGV ARGVOUT ENV INC SIG };
17
1813µsmy %forbidden = (%keywords, %forced_into_main);
19
2017µs13µsmy $normal_constant_name = qr/^_?[^\W_0-9]\w*\z/;
# spent 3µs making 1 call to constant::CORE:qr
2112µs11µsmy $tolerable = qr/^[A-Za-z_]\w*\z/;
# spent 1µs making 1 call to constant::CORE:qr
2212µs11µsmy $boolean = qr/^[01]?\z/;
# spent 1µs making 1 call to constant::CORE:qr
23
24
# spent 8µs (7+1000ns) within constant::BEGIN@24 which was called: # once (7µs+1000ns) by Feature::Compat::Try::BEGIN@13 at line 45
BEGIN {
25 # We'd like to do use constant _CAN_PCS => $] > 5.009002
26 # but that's a bit tricky before we load the constant module :-)
27 # By doing this, we save several run time checks for *every* call
28 # to import.
2910s my $const = $] > 5.009002;
3010s my $downgrade = $] < 5.015004; # && $] >= 5.008
3111µs my $constarray = exists &_make_const;
3212µs if ($const) {
3315µs11µs Internals::SvREADONLY($const, 1);
# spent 1µs making 1 call to Internals::SvREADONLY
3411µs10s Internals::SvREADONLY($downgrade, 1);
# spent 0s making 1 call to Internals::SvREADONLY
3510s $constant::{_CAN_PCS} = \$const;
3610s $constant::{_DOWNGRADE} = \$downgrade;
3710s $constant::{_CAN_PCS_FOR_ARRAY} = \$constarray;
38 }
39 else {
40277µs218µs
# spent 12µs (6+6) within constant::BEGIN@40 which was called: # once (6µs+6µs) by Feature::Compat::Try::BEGIN@13 at line 40
no strict 'refs';
# spent 12µs making 1 call to constant::BEGIN@40 # spent 6µs making 1 call to strict::unimport
41 *{"_CAN_PCS"} = sub () {$const};
42 *{"_DOWNGRADE"} = sub () { $downgrade };
43 *{"_CAN_PCS_FOR_ARRAY"} = sub () { $constarray };
44 }
45145µs18µs}
# spent 8µs making 1 call to constant::BEGIN@24
46
47#=======================================================================
48# import() - import symbols into user's namespace
49#
50# What we actually do is define a function in the caller's namespace
51# which returns the value. The function we create will normally
52# be inlined as a constant, thereby avoiding further sub calling
53# overhead.
54#=======================================================================
55
# spent 3.71ms (2.90+809µs) within constant::import which was called 160 times, avg 23µs/call: # once (144µs+46µs) by YAML::PP::Common::BEGIN@32 at line 55 of YAML/PP/Common.pm # once (92µs+16µs) by JSON::Schema::Modern::BEGIN@46 at line 46 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # once (87µs+8µs) by JSON::Schema::Modern::Result::BEGIN@70 at line 70 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Result.pm # once (65µs+11µs) by Mojo::Util::BEGIN@28 at line 36 of Mojo/Util.pm # once (56µs+17µs) by Path::Tiny::BEGIN@19 at line 27 of Path/Tiny.pm # once (44µs+26µs) by U64::BEGIN@835 at line 835 of IO/Compress/Base/Common.pm # once (51µs+8µs) by JSON::Schema::Modern::Document::OpenAPI::BEGIN@31 at line 31 of JSON/Schema/Modern/Document/OpenAPI.pm # once (51µs+5µs) by IO::Compress::Base::Common::BEGIN@50 at line 50 of IO/Compress/Base/Common.pm # once (34µs+14µs) by JSON::Schema::Modern::BEGIN@787 at line 791 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # once (33µs+12µs) by JSON::PP::IncrParser::BEGIN@1598 at line 1598 of JSON/PP.pm # once (33µs+12µs) by Data::Dumper::BEGIN@258 at line 258 of Data/Dumper.pm # once (31µs+13µs) by File::Spec::Unix::BEGIN@115 at line 115 of File/Spec/Unix.pm # once (29µs+14µs) by JSON::Schema::Modern::Utilities::BEGIN@53 at line 53 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern/Utilities.pm # once (39µs+4µs) by JSON::Schema::Modern::Document::OpenAPI::BEGIN@43 at line 43 of JSON/Schema/Modern/Document/OpenAPI.pm # once (30µs+12µs) by IO::Compress::Base::Common::BEGIN@45 at line 45 of IO/Compress/Base/Common.pm # once (28µs+13µs) by YAML::PP::Lexer::BEGIN@7 at line 7 of YAML/PP/Lexer.pm # once (36µs+5µs) by File::Spec::Unix::BEGIN@124 at line 124 of File/Spec/Unix.pm # once (32µs+9µs) by File::ShareDir::BEGIN@125 at line 125 of File/ShareDir.pm # once (28µs+13µs) by Encode::Alias::BEGIN@5 at line 5 of Encode/Alias.pm # once (24µs+16µs) by Feature::Compat::Try::BEGIN@13 at line 13 of Feature/Compat/Try.pm # once (26µs+13µs) by Mojo::Base::BEGIN@17 at line 17 of Mojo/Base.pm # once (28µs+11µs) by Mojo::Util::BEGIN@25 at line 25 of Mojo/Util.pm # once (29µs+9µs) by Encode::Encoding::BEGIN@14 at line 14 of Encode/Encoding.pm # once (26µs+12µs) by YAML::PP::Constructor::BEGIN@15 at line 15 of YAML/PP/Constructor.pm # once (25µs+12µs) by YAML::PP::Parser::BEGIN@8 at line 8 of YAML/PP/Parser.pm # once (28µs+9µs) by Getopt::Long::BEGIN@220 at line 220 of Getopt/Long.pm # once (28µs+9µs) by Getopt::Long::BEGIN@237 at line 237 of Getopt/Long.pm # once (24µs+13µs) by JSON::PP::BEGIN@24 at line 24 of JSON/PP.pm # once (26µs+10µs) by OpenAPI::Modern::BEGIN@32 at line 32 of OpenAPI/Modern.pm # once (25µs+11µs) by JSON::PP::IncrParser::BEGIN@1605 at line 1605 of JSON/PP.pm # once (24µs+12µs) by Try::Tiny::ScopeGuard::BEGIN@167 at line 167 of Try/Tiny.pm # once (24µs+12µs) by IO::Compress::Base::Common::BEGIN@480 at line 480 of IO/Compress/Base/Common.pm # once (25µs+10µs) by Compress::Raw::Zlib::BEGIN@105 at line 105 of Compress/Raw/Zlib.pm # once (27µs+8µs) by YAML::PP::Emitter::BEGIN@15 at line 15 of YAML/PP/Emitter.pm # once (27µs+8µs) by IO::Uncompress::Base::BEGIN@14 at line 14 of IO/Uncompress/Base.pm # once (25µs+10µs) by namespace::clean::_Util::BEGIN@18 at line 18 of namespace/clean/_Util.pm # once (25µs+9µs) by IO::Compress::Gzip::Constants::BEGIN@65 at line 65 of IO/Compress/Gzip/Constants.pm # once (25µs+9µs) by Data::Dumper::BEGIN@20 at line 20 of Data/Dumper.pm # once (25µs+8µs) by JSON::PP::IncrParser::BEGIN@1603 at line 1603 of JSON/PP.pm # once (25µs+8µs) by U64::BEGIN@838 at line 838 of IO/Compress/Base/Common.pm # once (23µs+7µs) by IO::Compress::Base::Common::BEGIN@495 at line 495 of IO/Compress/Base/Common.pm # once (22µs+8µs) by IO::Compress::Base::Common::BEGIN@481 at line 481 of IO/Compress/Base/Common.pm # once (21µs+8µs) by YAML::PP::Render::BEGIN@8 at line 8 of YAML/PP/Render.pm # once (22µs+7µs) by JSON::Schema::Modern::BEGIN@47 at line 47 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # once (23µs+4µs) by Mojo::Base::BEGIN@20 at line 22 of Mojo/Base.pm # once (20µs+5µs) by JSON::PP::IncrParser::BEGIN@1602 at line 1602 of JSON/PP.pm # once (18µs+6µs) by IO::Compress::Base::Common::BEGIN@148 at line 148 of IO/Compress/Base/Common.pm # once (16µs+5µs) by U64::BEGIN@836 at line 836 of IO/Compress/Base/Common.pm # once (17µs+4µs) by File::Spec::Unix::BEGIN@209 at line 209 of File/Spec/Unix.pm # once (15µs+5µs) by JSON::PP::IncrParser::BEGIN@1604 at line 1604 of JSON/PP.pm # once (14µs+6µs) by Encode::BEGIN@7 at line 7 of Encode.pm # once (17µs+3µs) by File::Spec::Unix::BEGIN@133 at line 133 of File/Spec/Unix.pm # once (15µs+5µs) by IO::Compress::Gzip::Constants::BEGIN@87 at line 87 of IO/Compress/Gzip/Constants.pm # once (15µs+4µs) by Compress::Raw::Zlib::BEGIN@118 at line 118 of Compress/Raw/Zlib.pm # once (17µs+2µs) by namespace::clean::_Util::BEGIN@19 at line 19 of namespace/clean/_Util.pm # once (16µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@92 at line 93 of IO/Compress/Gzip/Constants.pm # once (16µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@89 at line 89 of IO/Compress/Gzip/Constants.pm # once (14µs+4µs) by Getopt::Long::BEGIN@230 at line 230 of Getopt/Long.pm # once (14µs+4µs) by JSON::PP::IncrParser::BEGIN@1601 at line 1601 of JSON/PP.pm # once (12µs+6µs) by JSON::PP::BEGIN@25 at line 25 of JSON/PP.pm # once (14µs+4µs) by JSON::PP::BEGIN@26 at line 26 of JSON/PP.pm # once (14µs+4µs) by IO::Compress::Base::Common::BEGIN@500 at line 500 of IO/Compress/Base/Common.pm # once (13µs+5µs) by IO::Compress::Base::Common::BEGIN@484 at line 484 of IO/Compress/Base/Common.pm # once (14µs+4µs) by IO::Compress::Gzip::Constants::BEGIN@90 at line 91 of IO/Compress/Gzip/Constants.pm # once (13µs+4µs) by YAML::PP::Parser::BEGIN@9 at line 9 of YAML/PP/Parser.pm # once (15µs+2µs) by Compress::Raw::Zlib::BEGIN@137 at line 137 of Compress/Raw/Zlib.pm # once (13µs+4µs) by JSON::PP::BEGIN@40 at line 40 of JSON/PP.pm # once (12µs+5µs) by YAML::PP::Emitter::BEGIN@16 at line 16 of YAML/PP/Emitter.pm # once (13µs+4µs) by IO::Compress::Base::Common::BEGIN@499 at line 499 of IO/Compress/Base/Common.pm # once (14µs+3µs) by File::ShareDir::BEGIN@126 at line 126 of File/ShareDir.pm # once (14µs+3µs) by JSON::Schema::Modern::Document::OpenAPI::BEGIN@33 at line 41 of JSON/Schema/Modern/Document/OpenAPI.pm # once (14µs+2µs) by Compress::Raw::Zlib::BEGIN@106 at line 106 of Compress/Raw/Zlib.pm # once (12µs+4µs) by Getopt::Long::BEGIN@238 at line 238 of Getopt/Long.pm # once (12µs+4µs) by JSON::PP::BEGIN@47 at line 47 of JSON/PP.pm # once (13µs+3µs) by YAML::PP::Constructor::BEGIN@16 at line 16 of YAML/PP/Constructor.pm # once (12µs+4µs) by IO::Compress::Gzip::Constants::BEGIN@109 at line 109 of IO/Compress/Gzip/Constants.pm # once (14µs+2µs) by IO::Compress::Gzip::Constants::BEGIN@66 at line 66 of IO/Compress/Gzip/Constants.pm # once (12µs+4µs) by JSON::Schema::Modern::BEGIN@793 at line 816 of /Users/ether/git/JSON-Schema-Modern/lib/JSON/Schema/Modern.pm # once (11µs+4µs) by YAML::PP::Lexer::BEGIN@8 at line 8 of YAML/PP/Lexer.pm # once (12µs+3µs) by IO::Compress::Base::Common::BEGIN@490 at line 490 of IO/Compress/Base/Common.pm # once (12µs+3µs) by IO::Compress::Base::Common::BEGIN@51 at line 51 of IO/Compress/Base/Common.pm # once (13µs+2µs) by U64::BEGIN@837 at line 837 of IO/Compress/Base/Common.pm # once (12µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@84 at line 84 of IO/Compress/Gzip/Constants.pm # once (11µs+4µs) by IO::Compress::Gzip::Constants::BEGIN@143 at line 145 of IO/Compress/Gzip/Constants.pm # once (11µs+4µs) by IO::Compress::Gzip::Constants::BEGIN@67 at line 67 of IO/Compress/Gzip/Constants.pm # once (11µs+3µs) by Compress::Raw::Zlib::BEGIN@149 at line 149 of Compress/Raw/Zlib.pm # once (11µs+3µs) by Compress::Raw::Zlib::BEGIN@136 at line 136 of Compress/Raw/Zlib.pm # once (11µs+3µs) by Getopt::Long::BEGIN@236 at line 236 of Getopt/Long.pm # once (10µs+4µs) by Getopt::Long::BEGIN@234 at line 234 of Getopt/Long.pm # once (11µs+3µs) by Getopt::Long::BEGIN@232 at line 232 of Getopt/Long.pm # once (11µs+3µs) by JSON::PP::BEGIN@41 at line 41 of JSON/PP.pm # once (13µs+1µs) by JSON::PP::BEGIN@35 at line 35 of JSON/PP.pm # once (13µs+1µs) by JSON::PP::BEGIN@48 at line 48 of JSON/PP.pm # once (12µs+2µs) by JSON::PP::BEGIN@31 at line 31 of JSON/PP.pm # once (12µs+2µs) by IO::Uncompress::Base::BEGIN@15 at line 15 of IO/Uncompress/Base.pm # once (12µs+2µs) by IO::Compress::Base::Common::BEGIN@46 at line 46 of IO/Compress/Base/Common.pm # once (12µs+2µs) by IO::Compress::Base::Common::BEGIN@482 at line 482 of IO/Compress/Base/Common.pm # once (10µs+3µs) by Compress::Raw::Zlib::BEGIN@120 at line 120 of Compress/Raw/Zlib.pm # once (10µs+3µs) by Compress::Raw::Zlib::BEGIN@145 at line 145 of Compress/Raw/Zlib.pm # once (9µs+4µs) by Compress::Raw::Zlib::BEGIN@121 at line 121 of Compress/Raw/Zlib.pm # once (9µs+4µs) by Compress::Raw::Zlib::BEGIN@139 at line 139 of Compress/Raw/Zlib.pm # once (11µs+2µs) by Getopt::Long::BEGIN@259 at line 264 of Getopt/Long.pm # once (12µs+1000ns) by Getopt::Long::BEGIN@249 at line 258 of Getopt/Long.pm # once (12µs+1000ns) by JSON::PP::IncrParser::BEGIN@1600 at line 1600 of JSON/PP.pm # once (10µs+3µs) by JSON::PP::BEGIN@45 at line 45 of JSON/PP.pm # once (12µs+1000ns) by JSON::PP::IncrParser::BEGIN@1599 at line 1599 of JSON/PP.pm # once (13µs+0s) by JSON::PP::BEGIN@38 at line 38 of JSON/PP.pm # once (13µs+0s) by JSON::PP::BEGIN@30 at line 30 of JSON/PP.pm # once (10µs+3µs) by JSON::PP::BEGIN@28 at line 28 of JSON/PP.pm # once (10µs+3µs) by IO::Compress::Base::Common::BEGIN@48 at line 48 of IO/Compress/Base/Common.pm # once (10µs+3µs) by IO::Compress::Base::Common::BEGIN@494 at line 494 of IO/Compress/Base/Common.pm # once (12µs+1000ns) by IO::Compress::Base::Common::BEGIN@47 at line 47 of IO/Compress/Base/Common.pm # once (12µs+1000ns) by IO::Compress::Base::Common::BEGIN@483 at line 483 of IO/Compress/Base/Common.pm # once (10µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@115 at line 115 of IO/Compress/Gzip/Constants.pm # once (10µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@74 at line 74 of IO/Compress/Gzip/Constants.pm # once (10µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@111 at line 111 of IO/Compress/Gzip/Constants.pm # once (10µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@113 at line 113 of IO/Compress/Gzip/Constants.pm # once (12µs+1000ns) by IO::Compress::Gzip::Constants::BEGIN@70 at line 70 of IO/Compress/Gzip/Constants.pm # once (12µs+1000ns) by IO::Compress::Gzip::Constants::BEGIN@75 at line 75 of IO/Compress/Gzip/Constants.pm # once (9µs+3µs) by Compress::Raw::Zlib::BEGIN@147 at line 147 of Compress/Raw/Zlib.pm # once (10µs+2µs) by Compress::Raw::Zlib::BEGIN@138 at line 138 of Compress/Raw/Zlib.pm # once (9µs+3µs) by Getopt::Long::BEGIN@235 at line 235 of Getopt/Long.pm # once (9µs+3µs) by Getopt::Long::BEGIN@248 at line 248 of Getopt/Long.pm # once (9µs+3µs) by JSON::PP::BEGIN@34 at line 34 of JSON/PP.pm # once (11µs+1µs) by JSON::PP::BEGIN@27 at line 27 of JSON/PP.pm # once (9µs+3µs) by JSON::PP::BEGIN@37 at line 37 of JSON/PP.pm # once (12µs+0s) by IO::Compress::Base::Common::BEGIN@493 at line 493 of IO/Compress/Base/Common.pm # once (9µs+3µs) by IO::Compress::Base::Common::BEGIN@149 at line 149 of IO/Compress/Base/Common.pm # once (9µs+3µs) by IO::Compress::Base::Common::BEGIN@485 at line 485 of IO/Compress/Base/Common.pm # once (11µs+1µs) by IO::Compress::Base::Common::BEGIN@489 at line 489 of IO/Compress/Base/Common.pm # once (9µs+3µs) by IO::Compress::Base::Common::BEGIN@49 at line 49 of IO/Compress/Base/Common.pm # once (8µs+4µs) by IO::Compress::Base::Common::BEGIN@150 at line 150 of IO/Compress/Base/Common.pm # once (11µs+1µs) by IO::Compress::Gzip::Constants::BEGIN@88 at line 88 of IO/Compress/Gzip/Constants.pm # once (9µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@69 at line 69 of IO/Compress/Gzip/Constants.pm # once (11µs+0s) by Compress::Raw::Zlib::BEGIN@146 at line 146 of Compress/Raw/Zlib.pm # once (8µs+3µs) by Compress::Raw::Zlib::BEGIN@148 at line 148 of Compress/Raw/Zlib.pm # once (11µs+0s) by Compress::Raw::Zlib::BEGIN@122 at line 122 of Compress/Raw/Zlib.pm # once (10µs+1000ns) by Getopt::Long::BEGIN@240 at line 240 of Getopt/Long.pm # once (11µs+0s) by Getopt::Long::BEGIN@241 at line 241 of Getopt/Long.pm # once (11µs+0s) by JSON::PP::BEGIN@33 at line 33 of JSON/PP.pm # once (10µs+1000ns) by JSON::PP::BEGIN@39 at line 39 of JSON/PP.pm # once (9µs+2µs) by JSON::PP::BEGIN@32 at line 32 of JSON/PP.pm # once (8µs+3µs) by File::Spec::Unix::BEGIN@231 at line 231 of File/Spec/Unix.pm # once (8µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@114 at line 114 of IO/Compress/Gzip/Constants.pm # once (11µs+0s) by IO::Compress::Gzip::Constants::BEGIN@86 at line 86 of IO/Compress/Gzip/Constants.pm # once (10µs+1000ns) by IO::Compress::Gzip::Constants::BEGIN@76 at line 76 of IO/Compress/Gzip/Constants.pm # once (9µs+1µs) by Compress::Raw::Zlib::BEGIN@150 at line 150 of Compress/Raw/Zlib.pm # once (9µs+1µs) by JSON::PP::BEGIN@29 at line 29 of JSON/PP.pm # once (10µs+0s) by JSON::PP::BEGIN@44 at line 44 of JSON/PP.pm # once (10µs+0s) by IO::Compress::Base::Common::BEGIN@492 at line 492 of IO/Compress/Base/Common.pm # once (8µs+2µs) by IO::Compress::Base::Common::BEGIN@152 at line 152 of IO/Compress/Base/Common.pm # once (10µs+0s) by IO::Compress::Gzip::Constants::BEGIN@119 at line 119 of IO/Compress/Gzip/Constants.pm # once (7µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@80 at line 80 of IO/Compress/Gzip/Constants.pm # once (7µs+2µs) by Compress::Raw::Zlib::BEGIN@119 at line 119 of Compress/Raw/Zlib.pm # once (7µs+2µs) by JSON::PP::BEGIN@42 at line 42 of JSON/PP.pm # once (8µs+1µs) by IO::Compress::Gzip::Constants::BEGIN@78 at line 78 of IO/Compress/Gzip/Constants.pm # once (6µs+3µs) by IO::Compress::Gzip::Constants::BEGIN@82 at line 82 of IO/Compress/Gzip/Constants.pm # once (8µs+1µs) by IO::Compress::Gzip::Constants::BEGIN@77 at line 77 of IO/Compress/Gzip/Constants.pm # once (7µs+1000ns) by JSON::PP::BEGIN@49 at line 49 of JSON/PP.pm # once (6µs+2µs) by IO::Compress::Gzip::Constants::BEGIN@73 at line 73 of IO/Compress/Gzip/Constants.pm
sub import {
5616035µs my $class = shift;
5716036µs return unless @_; # Ignore 'use constant;'
5816019µs my $constants;
5916046µs my $multiple = ref $_[0];
6016050µs my $caller = caller;
6116020µs my $flush_mro;
62 my $symtab;
63
6416049µs if (_CAN_PCS) {
65289µs29µs
# spent 7µs (5+2) within constant::BEGIN@65 which was called: # once (5µs+2µs) by Feature::Compat::Try::BEGIN@13 at line 65
no strict 'refs';
# spent 7µs making 1 call to constant::BEGIN@65 # spent 2µs making 1 call to strict::unimport
6616085µs $symtab = \%{$caller . '::'};
67 };
68
6916036µs if ( $multiple ) {
7054µs if (ref $_[0] ne 'HASH') {
71 require Carp;
72 Carp::croak("Invalid reference type '".ref(shift)."' not 'HASH'");
73 }
7450s $constants = shift;
75 } else {
7615518µs unless (defined $_[0]) {
77 require Carp;
78 Carp::croak("Can't use undef as constant name");
79 }
80155115µs $constants->{+shift} = undef;
81 }
82
83160112µs foreach my $name ( keys %$constants ) {
8419119µs my $pkg;
8519116µs my $symtab = $symtab;
8619129µs my $orig_name = $name;
87191522µs191234µs if ($name =~ s/(.*)(?:::|')(?=.)//s) {
# spent 234µs making 191 calls to constant::CORE:subst, avg 1µs/call
88 $pkg = $1;
89 if (_CAN_PCS && $pkg ne $caller) {
902112µs211µs
# spent 8µs (5+3) within constant::BEGIN@90 which was called: # once (5µs+3µs) by Feature::Compat::Try::BEGIN@13 at line 90
no strict 'refs';
# spent 8µs making 1 call to constant::BEGIN@90 # spent 3µs making 1 call to strict::unimport
91 $symtab = \%{$pkg . '::'};
92 }
93 }
94 else {
9519125µs $pkg = $caller;
96 }
97
98 # Normal constant name
99191854µs382407µs if ($name =~ $normal_constant_name and !$forbidden{$name}) {
# spent 230µs making 191 calls to constant::CORE:match, avg 1µs/call # spent 177µs making 191 calls to constant::CORE:regcomp, avg 927ns/call
100 # Everything is okay
101
102 # Name forced into main, but we're not in main. Fatal.
103 } elsif ($forced_into_main{$name} and $pkg ne 'main') {
104 require Carp;
105 Carp::croak("Constant name '$name' is forced into main::");
106
107 # Starts with double underscore. Fatal.
108 } elsif ($name =~ /^__/) {
109 require Carp;
110 Carp::croak("Constant name '$name' begins with '__'");
111
112 # Maybe the name is tolerable
113 } elsif ($name =~ $tolerable) {
114 # Then we'll warn only if you've asked for warnings
115 if (warnings::enabled()) {
116 if ($keywords{$name}) {
117 warnings::warn("Constant name '$name' is a Perl keyword");
118 } elsif ($forced_into_main{$name}) {
119 warnings::warn("Constant name '$name' is " .
120 "forced into package main::");
121 }
122 }
123
124 # Looks like a boolean
125 # use constant FRED == fred;
126 } elsif ($name =~ $boolean) {
127 require Carp;
128 if (@_) {
129 Carp::croak("Constant name '$name' is invalid");
130 } else {
131 Carp::croak("Constant name looks like boolean value");
132 }
133
134 } else {
135 # Must have bad characters
136 require Carp;
137 Carp::croak("Constant name '$name' has invalid characters");
138 }
139
140 {
141193336µs27µs
# spent 5µs (3+2) within constant::BEGIN@141 which was called: # once (3µs+2µs) by Feature::Compat::Try::BEGIN@13 at line 141
no strict 'refs';
# spent 5µs making 1 call to constant::BEGIN@141 # spent 2µs making 1 call to strict::unimport
14219134µs my $full_name = "${pkg}::$name";
143191150µs $declared{$full_name}++;
14419194µs if ($multiple || @_ == 1) {
14519130µs my $scalar = $multiple ? $constants->{$orig_name} : $_[0];
146
147 if (_DOWNGRADE) { # for 5.8 to 5.14
148 # Work around perl bug #31991: Sub names (actually glob
149 # names in general) ignore the UTF8 flag. So we have to
150 # turn it off to get the "right" symbol table entry.
151 utf8::is_utf8 $name and utf8::encode $name;
152 }
153
154 # The constant serves to optimise this entire block out on
155 # 5.8 and earlier.
15619143µs if (_CAN_PCS) {
157 # Use a reference as a proxy for a constant subroutine.
158 # If this is not a glob yet, it saves space. If it is
159 # a glob, we must still create it this way to get the
160 # right internal flags set, as constants are distinct
161 # from subroutines created with sub(){...}.
162 # The check in Perl_ck_rvconst knows that inlinable
163 # constants from cv_const_sv are read only. So we have to:
164191368µs19175µs Internals::SvREADONLY($scalar, 1);
# spent 75µs making 191 calls to Internals::SvREADONLY, avg 393ns/call
16519158µs if (!exists $symtab->{$name}) {
16619163µs $symtab->{$name} = \$scalar;
16719173µs ++$flush_mro->{$pkg};
168 }
169 else {
170 local $constant::{_dummy} = \$scalar;
171 *$full_name = \&{"_dummy"};
172 }
173 } else {
174 *$full_name = sub () { $scalar };
175 }
176 } elsif (@_) {
177 my @list = @_;
178 if (_CAN_PCS_FOR_ARRAY) {
179 _make_const($list[$_]) for 0..$#list;
180 _make_const(@list);
181 if (!exists $symtab->{$name}) {
182 $symtab->{$name} = \@list;
183 $flush_mro->{$pkg}++;
184 }
185 else {
186 local $constant::{_dummy} = \@list;
187 *$full_name = \&{"_dummy"};
188 }
189 }
190 else { *$full_name = sub () { @list }; }
191 } else {
192 *$full_name = sub () { };
193 }
194 }
195 }
196 # Flush the cache exactly once if we make any direct symbol table changes.
197160449µs if (_CAN_PCS && $flush_mro) {
198160352µs16093µs mro::method_changed_in($_) for keys %$flush_mro;
# spent 93µs making 160 calls to mro::method_changed_in, avg 581ns/call
199 }
200}
201
20217µs1;
203
204__END__
 
# spent 230µs within constant::CORE:match which was called 191 times, avg 1µs/call: # 191 times (230µs+0s) by constant::import at line 99, avg 1µs/call
sub constant::CORE:match; # opcode
# spent 5µs within constant::CORE:qr which was called 3 times, avg 2µs/call: # once (3µs+0s) by Feature::Compat::Try::BEGIN@13 at line 20 # once (1µs+0s) by Feature::Compat::Try::BEGIN@13 at line 21 # once (1µs+0s) by Feature::Compat::Try::BEGIN@13 at line 22
sub constant::CORE:qr; # opcode
# spent 177µs within constant::CORE:regcomp which was called 191 times, avg 927ns/call: # 191 times (177µs+0s) by constant::import at line 99, avg 927ns/call
sub constant::CORE:regcomp; # opcode
# spent 234µs within constant::CORE:subst which was called 191 times, avg 1µs/call: # 191 times (234µs+0s) by constant::import at line 87, avg 1µs/call
sub constant::CORE:subst; # opcode