← Index
NYTProf Performance Profile   « line view »
For -e
  Run on Thu Jun 30 16:34:56 2016
Reported on Thu Jun 30 16:35:08 2016

Filename/home/s1/perl5/perlbrew/perls/perl-5.22.1/lib/site_perl/5.22.1/Parse/Number/EN.pm
StatementsExecuted 14 statements in 1.22ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
111924µs936µsParse::Number::EN::::BEGIN@12Parse::Number::EN::BEGIN@12
11136µs36µsParse::Number::EN::::BEGIN@8Parse::Number::EN::BEGIN@8
11111µs15µsParse::Number::EN::::BEGIN@9Parse::Number::EN::BEGIN@9
11110µs17µsParse::Number::EN::::BEGIN@10Parse::Number::EN::BEGIN@10
0000s0sParse::Number::EN::::parse_number_enParse::Number::EN::parse_number_en
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1package Parse::Number::EN;
2
31500nsour $DATE = '2016-06-14'; # DATE
41200nsour $VERSION = '0.07'; # VERSION
5
6# TODO: make it OO and customize thousand sep & decimal point
7
8263µs136µs
# spent 36µs within Parse::Number::EN::BEGIN@8 which was called: # once (36µs+0s) by DateTime::Format::Alami::EN::BEGIN@14 at line 8
use 5.010001;
# spent 36µs making 1 call to Parse::Number::EN::BEGIN@8
9230µs220µs
# spent 15µs (11+5) within Parse::Number::EN::BEGIN@9 which was called: # once (11µs+5µs) by DateTime::Format::Alami::EN::BEGIN@14 at line 9
use strict;
# spent 15µs making 1 call to Parse::Number::EN::BEGIN@9 # spent 5µs making 1 call to strict::import
10231µs224µs
# spent 17µs (10+7) within Parse::Number::EN::BEGIN@10 which was called: # once (10µs+7µs) by DateTime::Format::Alami::EN::BEGIN@14 at line 10
use warnings;
# spent 17µs making 1 call to Parse::Number::EN::BEGIN@10 # spent 7µs making 1 call to warnings::import
11
1221.08ms2948µs
# spent 936µs (924+12) within Parse::Number::EN::BEGIN@12 which was called: # once (924µs+12µs) by DateTime::Format::Alami::EN::BEGIN@14 at line 12
use Exporter qw(import);
# spent 936µs making 1 call to Parse::Number::EN::BEGIN@12 # spent 12µs making 1 call to Exporter::import
1311µsour @EXPORT_OK = qw($Pat parse_number_en);
14
15our %SPEC;
16
17#our $Pat = qr/(?:
18# [+-]?
19# (?:
20# (?:\d{1,3}(?:[,]\d{3})+ | \d+) (?:[.]\d*)? | # english
21# [.]\d+
22# )
23# (?:[Ee][+-]?\d+)?
24# )/x;
25
26# non /x version
271100nsour $Pat = '(?:[+-]?(?:(?:\d{1,3}(?:[,]\d{3})+|\d+)(?:[.]\d*)?|[.]\d+)(?:[Ee][+-]?\d+)?)';
28
29$SPEC{parse_number_en} = {
3015µs v => 1.1,
31 summary => 'Parse number from English text',
32 description => <<'_',
33
34This function can parse number with thousand separators (e.g. 10,000).
35
36In the future percentage (e.g. 10.2%) and fractions (e.g. 1/3, 2 1/2) might also
37be supported.
38
39_
40 args => {
41 text => {
42 summary => 'The input text that contains number',
43 schema => 'str*',
44 req => 1,
45 pos => 0,
46 },
47 },
48 result_naked => 1,
49};
50sub parse_number_en {
51 my %args = @_;
52 my $text = $args{text};
53
54 return undef unless $text =~ s/^\s*($Pat)//s;
55 my $n = $1;
56 $n =~ s/,//g;
57 $n+0;
58}
59
6017µs1;
61# ABSTRACT: Parse number from English text
62
63__END__