← Index
NYTProf Performance Profile   « block view • line view • sub view »
For xt/tapper-mcp-scheduler-with-db-longrun.t
  Run on Tue May 22 17:18:39 2012
Reported on Tue May 22 17:23:53 2012

Filename/2home/ss5/perl5/perlbrew/perls/perl-5.12.3/lib/site_perl/5.12.3/Kwalify.pm
StatementsExecuted 3290 statements in 5.99ms
Subroutines
Calls P F Exclusive
Time
Inclusive
Time
Subroutine
22111.28ms4.24msKwalify::Validator::::validate_mapKwalify::Validator::validate_map
8931626µs4.71msKwalify::Validator::::_validateKwalify::Validator::_validate (recurses: max depth 2, inclusive time 5.82ms)
6621465µs595µsKwalify::Validator::::_additional_rulesKwalify::Validator::_additional_rules
15431429µs475µsKwalify::Validator::::_append_pathKwalify::Validator::_append_path
39641288µs288µsKwalify::Validator::::CORE:matchKwalify::Validator::CORE:match (opcode)
13331241µs321µsKwalify::Validator::::_get_booleanKwalify::Validator::_get_boolean
4411191µs624µsKwalify::Validator::::validate_strKwalify::Validator::validate_str
111142µs4.69msKwalify::Validator::::validate_seqKwalify::Validator::validate_seq
221163µs256µsKwalify::Validator::::validate_anyKwalify::Validator::validate_any
11123µs4.76msKwalify::::validate Kwalify::validate
11113µs17µsKwalify::::BEGIN@16 Kwalify::BEGIN@16
11111µs11µsKwalify::Validator::::newKwalify::Validator::new
11110µs17µsKwalify::Validator::::BEGIN@142Kwalify::Validator::BEGIN@142
1118µs24µsKwalify::Validator::::BEGIN@121Kwalify::Validator::BEGIN@121
1118µs79µsKwalify::::BEGIN@18 Kwalify::BEGIN@18
1117µs4.72msKwalify::Validator::::validateKwalify::Validator::validate
1117µs39µsKwalify::::BEGIN@19 Kwalify::BEGIN@19
1114µs4µsKwalify::::BEGIN@24 Kwalify::BEGIN@24
1114µs4µsKwalify::Validator::::BEGIN@45Kwalify::Validator::BEGIN@45
0000s0sKwalify::Validator::::__ANON__[:143]Kwalify::Validator::__ANON__[:143]
0000s0sKwalify::Validator::::__ANON__[:144]Kwalify::Validator::__ANON__[:144]
0000s0sKwalify::Validator::::__ANON__[:145]Kwalify::Validator::__ANON__[:145]
0000s0sKwalify::Validator::::__ANON__[:146]Kwalify::Validator::__ANON__[:146]
0000s0sKwalify::Validator::::_base_pathKwalify::Validator::_base_path
0000s0sKwalify::Validator::::_dieKwalify::Validator::_die
0000s0sKwalify::Validator::::_errorKwalify::Validator::_error
0000s0sKwalify::Validator::::validate_boolKwalify::Validator::validate_bool
0000s0sKwalify::Validator::::validate_dateKwalify::Validator::validate_date
0000s0sKwalify::Validator::::validate_floatKwalify::Validator::validate_float
0000s0sKwalify::Validator::::validate_intKwalify::Validator::validate_int
0000s0sKwalify::Validator::::validate_numberKwalify::Validator::validate_number
0000s0sKwalify::Validator::::validate_scalarKwalify::Validator::validate_scalar
0000s0sKwalify::Validator::::validate_textKwalify::Validator::validate_text
0000s0sKwalify::Validator::::validate_timeKwalify::Validator::validate_time
0000s0sKwalify::Validator::::validate_timestampKwalify::Validator::validate_timestamp
0000s0sKwalify::::__ANON__[:27] Kwalify::__ANON__[:27]
0000s0sKwalify::::__ANON__[:28] Kwalify::__ANON__[:28]
Call graph for these subroutines as a Graphviz dot language file.
Line State
ments
Time
on line
Calls Time
in subs
Code
1# -*- mode: cperl; coding: latin-2 -*-
2
3#
4# Author: Slaven Rezic
5#
6# Copyright (C) 2006,2007,2008,2009 Slaven Rezic. All rights reserved.
7# This package is free software; you can redistribute it and/or
8# modify it under the same terms as Perl itself.
9#
10# Mail: srezic@cpan.org
11# WWW: http://www.rezic.de/eserte/
12#
13
14package Kwalify;
15
16322µs220µs
# spent 17µs (13+3) within Kwalify::BEGIN@16 which was called: # once (13µs+3µs) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 16
use strict;
# spent 17µs making 1 call to Kwalify::BEGIN@16 # spent 3µs making 1 call to strict::import
17
18322µs2150µs
# spent 79µs (8+71) within Kwalify::BEGIN@18 which was called: # once (8µs+71µs) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 18
use base qw(Exporter);
# spent 79µs making 1 call to Kwalify::BEGIN@18 # spent 71µs making 1 call to base::import
19381µs271µs
# spent 39µs (7+32) within Kwalify::BEGIN@19 which was called: # once (7µs+32µs) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 19
use vars qw(@EXPORT_OK $VERSION);
# spent 39µs making 1 call to Kwalify::BEGIN@19 # spent 32µs making 1 call to vars::import
2012µs@EXPORT_OK = qw(validate);
21
221300ns$VERSION = '1.21';
23
24
# spent 4µs within Kwalify::BEGIN@24 which was called: # once (4µs+0s) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 30
BEGIN {
2515µs if ($] < 5.006) {
26 $INC{"warnings.pm"} = 1;
27 *warnings::import = sub { };
28 *warnings::unimport = sub { };
29 }
30199µs14µs}
# spent 4µs making 1 call to Kwalify::BEGIN@24
31
32
# spent 4.76ms (23µs+4.73) within Kwalify::validate which was called: # once (23µs+4.73ms) by Test::Fixture::DBIC::Schema::_validate_fixture at line 43 of Test/Fixture/DBIC/Schema.pm
sub validate ($$) {
3311µs my($schema, $data) = @_;
3416µs111µs my $self = Kwalify::Validator->new;
# spent 11µs making 1 call to Kwalify::Validator::new
3513µs14.72ms $self->validate($schema, $data, "/");
# spent 4.72ms making 1 call to Kwalify::Validator::validate
36111µs if (@{$self->{errors}}) {
37 die join("\n", map { " - $_" } @{$self->{errors}}) . "\n";
38 } else {
391300ns 1;
40 }
41}
42
43package Kwalify::Validator;
44
453382µs14µs
# spent 4µs within Kwalify::Validator::BEGIN@45 which was called: # once (4µs+0s) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 45
use overload ();
# spent 4µs making 1 call to Kwalify::Validator::BEGIN@45
46
47
# spent 11µs within Kwalify::Validator::new which was called: # once (11µs+0s) by Kwalify::validate at line 34
sub new {
481700ns my($class) = @_;
49112µs bless { errors => [] }, $class;
50}
51
52
# spent 4.72ms (7µs+4.71) within Kwalify::Validator::validate which was called: # once (7µs+4.71ms) by Kwalify::validate at line 35
sub validate {
5311µs my($self, $schema, $data, $path, $args) = @_;
5411µs $self->{done} = {};
5516µs14.71ms $self->_validate($schema, $data, $path, $args);
# spent 4.71ms making 1 call to Kwalify::Validator::_validate
56}
57
58
# spent 4.71ms (626µs+4.09) within Kwalify::Validator::_validate which was called 89 times, avg 53µs/call: # 66 times (449µs+-449µs) by Kwalify::Validator::validate_map at line 366, avg 0s/call # 22 times (156µs+-156µs) by Kwalify::Validator::validate_seq at line 289, avg 0s/call # once (21µs+4.69ms) by Kwalify::Validator::validate at line 55
sub _validate {
598948µs my($self, $schema, $data, $path, $args) = @_;
608925µs $self->{path} = $path;
61
6289161µs8943µs if (!UNIVERSAL::isa($schema, "HASH")) {
# spent 43µs making 89 calls to UNIVERSAL::isa, avg 489ns/call
63 $self->_die("Schema structure must be a hash reference");
64 }
65
668928µs my $type = $schema->{type};
678913µs if (!defined $type) {
68 $type = 'str'; # default type;
69 }
708929µs my $type_check_method = "validate_" . $type;
7189197µs8963µs if (!$self->can($type_check_method)) {
# spent 63µs making 89 calls to UNIVERSAL::can, avg 706ns/call
72 $self->_die("Invalid or unimplemented type '$type'");
73 }
74
7589228µs899.81ms $self->$type_check_method($schema, $data, $path, $args);
# spent 4.69ms making 1 call to Kwalify::Validator::validate_seq # spent 4.24ms making 22 calls to Kwalify::Validator::validate_map, avg 193µs/call # spent 624µs making 44 calls to Kwalify::Validator::validate_str, avg 14µs/call # spent 256µs making 22 calls to Kwalify::Validator::validate_any, avg 12µs/call
76}
77
78
# spent 595µs (465+130) within Kwalify::Validator::_additional_rules which was called 66 times, avg 9µs/call: # 44 times (315µs+87µs) by Kwalify::Validator::validate_str at line 196, avg 9µs/call # 22 times (150µs+43µs) by Kwalify::Validator::validate_any at line 259, avg 9µs/call
sub _additional_rules {
796631µs my($self, $schema, $data, $path) = @_;
8066144µs for my $schema_key (keys %$schema) {
81132106µs if (defined $schema->{$schema_key}) {
82132360µs132130µs if ($schema_key eq 'pattern') {
# spent 130µs making 132 calls to Kwalify::Validator::CORE:match, avg 987ns/call
83 (my $pattern = $schema->{pattern}) =~ s{^/(.*)/$}{$1};
84 if ($data !~ qr{$pattern}) {
85 $self->_error("Non-valid data '$data' does not match /$pattern/");
86 }
87 } elsif ($schema_key eq 'length') {
88 if (!UNIVERSAL::isa($schema->{'length'}, "HASH")) {
89 $self->_die("'length' must be a hash with keys max and/or min");
90 }
91 my $length = length($data);
92 for my $sub_schema_key (keys %{ $schema->{'length'} }) {
93 if ($sub_schema_key eq 'min') {
94 my $min = $schema->{'length'}->{min};
95 if ($length < $min) {
96 $self->_error("'$data' is too short (length $length < min $min)");
97 }
98 } elsif ($sub_schema_key eq 'min-ex') {
99 my $min = $schema->{'length'}->{'min-ex'};
100 if ($length <= $min) {
101 $self->_error("'$data' is too short (length $length <= min $min)");
102 }
103 } elsif ($sub_schema_key eq 'max') {
104 my $max = $schema->{'length'}->{max};
105 if ($length > $max) {
106 $self->_error("'$data' is too long (length $length > max $max)");
107 }
108 } elsif ($sub_schema_key eq 'max-ex') {
109 my $max = $schema->{'length'}->{'max-ex'};
110 if ($length >= $max) {
111 $self->_error("'$data' is too long (length $length >= max $max)");
112 }
113 } else {
114 $self->_die("Unexpected key '$sub_schema_key' in length specification, expected min, max, min-ex and/or max-ex");
115 }
116 }
117 } elsif ($schema_key eq 'enum') {
118 if (!UNIVERSAL::isa($schema->{enum}, 'ARRAY')) {
119 $self->_die("'enum' must be an array");
120 }
121398µs239µs
# spent 24µs (8+15) within Kwalify::Validator::BEGIN@121 which was called: # once (8µs+15µs) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 121
no warnings 'uninitialized'; # undef amongst the enum values may be intended!
# spent 24µs making 1 call to Kwalify::Validator::BEGIN@121 # spent 15µs making 1 call to warnings::unimport
122 my %valid = map { ($_,1) } @{ $schema->{enum} };
123 if (!exists $valid{$data}) {
124 $self->_error("'$data': invalid " . _base_path($path) . " value");
125 }
126 } elsif ($schema_key eq 'range') {
127 if (!UNIVERSAL::isa($schema->{range}, "HASH")) {
128 $self->_die("'range' must be a hash with keys max and/or min");
129 }
130 my($lt, $le, $gt, $ge);
131 ## yes? no?
132 # if (eval { require Scalar::Util; defined &Scalar::Util::looks_like_number }) {
133 # if (Scalar::Util::looks_like_number($data)) {
134 # $lt = sub { $_[0] < $_[1] };
135 # $gt = sub { $_[0] > $_[1] };
136 # } else {
137 # $lt = sub { $_[0] lt $_[1] };
138 # $gt = sub { $_[0] gt $_[1] };
139 # }
140 # } else {
141 # warn "Cannot determine whether $data is a number, assume so..."; # XXX show only once
14231.41ms224µs
# spent 17µs (10+7) within Kwalify::Validator::BEGIN@142 which was called: # once (10µs+7µs) by Test::Fixture::DBIC::Schema::BEGIN@8 at line 142
no warnings 'numeric';
# spent 17µs making 1 call to Kwalify::Validator::BEGIN@142 # spent 7µs making 1 call to warnings::unimport
143 $lt = sub { $_[0] < $_[1] };
144 $gt = sub { $_[0] > $_[1] };
145 $le = sub { $_[0] <= $_[1] };
146 $ge = sub { $_[0] >= $_[1] };
147 # }
148
149 for my $sub_schema_key (keys %{ $schema->{range} }) {
150 if ($sub_schema_key eq 'min') {
151 my $min = $schema->{range}->{min};
152 if ($lt->($data, $min)) {
153 $self->_error("'$data' is too small (< min $min)");
154 }
155 } elsif ($sub_schema_key eq 'min-ex') {
156 my $min = $schema->{range}->{'min-ex'};
157 if ($le->($data, $min)) {
158 $self->_error("'$data' is too small (<= min $min)");
159 }
160 } elsif ($sub_schema_key eq 'max') {
161 my $max = $schema->{range}->{max};
162 if ($gt->($data, $max)) {
163 $self->_error("'$data' is too large (> max $max)");
164 }
165 } elsif ($sub_schema_key eq 'max-ex') {
166 my $max = $schema->{range}->{'max-ex'};
167 if ($ge->($data, $max)) {
168 $self->_error("'$data' is too large (>= max $max)");
169 }
170 } else {
171 $self->_die("Unexpected key '$sub_schema_key' in range specification, expected min, max, min-ex and/or max-ex");
172 }
173 }
174 } elsif ($schema_key eq 'assert') {
175 $self->_die("'assert' is not yet implemented");
176 } elsif ($schema_key !~ m{^(type|required|unique|name|classname|class|desc)$}) {
177 $self->_die("Unexpected key '$schema_key' in type specification");
178 }
179 }
180 }
181}
182
183sub validate_text {
184 my($self, $schema, $data, $path) = @_;
185 if (!defined $data || ref $data) {
186 return $self->_error("Non-valid data '" . (defined $data ? $data : 'undef') . "', expected text");
187 }
188 $self->_additional_rules($schema, $data, $path);
189}
190
191
# spent 624µs (191+433) within Kwalify::Validator::validate_str which was called 44 times, avg 14µs/call: # 44 times (191µs+433µs) by Kwalify::Validator::_validate at line 75, avg 14µs/call
sub validate_str {
1924422µs my($self, $schema, $data, $path) = @_;
1934495µs4432µs if (!defined $data || ref $data || $data =~ m{^\d+(\.\d+)?$}) {
# spent 32µs making 44 calls to Kwalify::Validator::CORE:match, avg 725ns/call
194 return $self->_error("Non-valid data '" . (defined $data ? $data : 'undef') . "', expected a str");
195 }
19644103µs44402µs $self->_additional_rules($schema, $data, $path);
# spent 402µs making 44 calls to Kwalify::Validator::_additional_rules, avg 9µs/call
197}
198
199sub validate_int {
200 my($self, $schema, $data, $path) = @_;
201 if ($data !~ m{^[+-]?\d+$}) { # XXX what about scientific notation?
202 $self->_error("Non-valid data '" . $data . "', expected an int");
203 }
204 $self->_additional_rules($schema, $data, $path);
205}
206
207sub validate_float {
208 my($self, $schema, $data, $path) = @_;
209 if ($data !~ m{^[+-]?\d+\.\d+$}) { # XXX other values?
210 $self->_error("Non-valid data '" . $data . "', expected a float");
211 }
212 $self->_additional_rules($schema, $data, $path);
213}
214
215sub validate_number {
216 my($self, $schema, $data, $path) = @_;
217 if ($data !~ m{^[+-]?\d+(\.\d+)?$}) { # XXX combine int+float regexp!
218 $self->_error("Non-valid data '" . $data . "', expected a number");
219 }
220 $self->_additional_rules($schema, $data, $path);
221}
222
223sub validate_bool {
224 my($self, $schema, $data, $path) = @_;
225 if ($data !~ m{^(yes|true|1|no|false|0)$}) { # XXX correct?
226 $self->_error("Non-valid data '" . $data . "', expected a boolean");
227 }
228 $self->_additional_rules($schema, $data, $path);
229}
230
231# XXX is this correct?
232sub validate_scalar {
233 shift->validate_text(@_);
234}
235
236sub validate_date {
237 my($self, $schema, $data, $path) = @_;
238 if ($data !~ m{^\d{4}-\d{2}-\d{2}$}) {
239 $self->_error("Non-valid data '" . $data . "', expected a date (YYYY-MM-DD)");
240 }
241 $self->_additional_rules($schema, $data, $path);
242}
243
244sub validate_time {
245 my($self, $schema, $data, $path) = @_;
246 if ($data !~ m{^\d{2}:\d{2}:\d{2}$}) {
247 $self->_error("Non-valid data '" . $data . "', expected a time (HH:MM:SS)");
248 }
249 $self->_additional_rules($schema, $data, $path);
250}
251
252sub validate_timestamp {
253 my($self) = @_;
254 $self->_error("timestamp validation NYI"); # XXX
255}
256
257
# spent 256µs (63+194) within Kwalify::Validator::validate_any which was called 22 times, avg 12µs/call: # 22 times (63µs+194µs) by Kwalify::Validator::_validate at line 75, avg 12µs/call
sub validate_any {
2582210µs my($self, $schema, $data, $path) = @_;
2592250µs22194µs $self->_additional_rules($schema, $data, $path);
# spent 194µs making 22 calls to Kwalify::Validator::_additional_rules, avg 9µs/call
260}
261
262
# spent 4.69ms (142µs+4.55) within Kwalify::Validator::validate_seq which was called: # once (142µs+4.55ms) by Kwalify::Validator::_validate at line 75
sub validate_seq {
26311µs my($self, $schema, $data, $path) = @_;
2641800ns if (!exists $schema->{sequence}) {
265 $self->_die("'sequence' missing with 'seq' type");
266 }
2671600ns my $sequence = $schema->{sequence};
26813µs1500ns if (!UNIVERSAL::isa($sequence, 'ARRAY')) {
# spent 500ns making 1 call to UNIVERSAL::isa
269 $self->_die("Expected array in 'sequence'");
270 }
27111µs if (@$sequence != 1) {
272 $self->_die("Expect exactly one element in sequence");
273 }
27413µs1500ns if (!UNIVERSAL::isa($data, 'ARRAY')) {
# spent 500ns making 1 call to UNIVERSAL::isa
275 $self->_error("Non-valid data " . $data . ", expected sequence");
276 return;
277 }
278
27915µs236µs return if ($self->{done}{overload::StrVal($data)}{overload::StrVal($schema)});
# spent 36µs making 2 calls to overload::AddrRef, avg 18µs/call
28013µs217µs $self->{done}{overload::StrVal($data)}{overload::StrVal($schema)} = 1;
# spent 17µs making 2 calls to overload::AddrRef, avg 9µs/call
281
2821800ns my $subschema = $sequence->[0];
28314µs13µs my $unique = _get_boolean($subschema->{unique});
# spent 3µs making 1 call to Kwalify::Validator::_get_boolean
2841200ns my %unique_val;
2851400ns my %unique_mapping_val;
2861300ns my $index = 0;
28716µs for my $elem (@$data) {
2882223µs2273µs my $subpath = _append_path($path, $index);
# spent 73µs making 22 calls to Kwalify::Validator::_append_path, avg 3µs/call
2892247µs220s $self->_validate($subschema, $elem, $subpath, { unique_mapping_val => \%unique_mapping_val});
# spent 4.42ms making 22 calls to Kwalify::Validator::_validate, avg 201µs/call, recursion: max depth 1, sum of overlapping time 4.42ms
290223µs if ($unique) {
291 if (exists $unique_val{$elem}) {
292 $self->_error("'$elem' is already used at '$unique_val{$elem}'");
293 } else {
294 $unique_val{$elem} = $subpath;
295 }
296 }
297229µs $index++;
298 }
299}
300
301
# spent 4.24ms (1.28+2.96) within Kwalify::Validator::validate_map which was called 22 times, avg 193µs/call: # 22 times (1.28ms+2.96ms) by Kwalify::Validator::_validate at line 75, avg 193µs/call
sub validate_map {
3022211µs my($self, $schema, $data, $path, $args) = @_;
303223µs my $unique_mapping_val;
3042210µs if ($args && $args->{unique_mapping_val}) {
305 $unique_mapping_val = $args->{unique_mapping_val};
306 }
307226µs if (!exists $schema->{mapping}) {
308 $self->_die("'mapping' missing with 'map' type");
309 }
310225µs my $mapping = $schema->{mapping};
3112238µs2210µs if (!UNIVERSAL::isa($mapping, 'HASH')) {
# spent 10µs making 22 calls to UNIVERSAL::isa, avg 441ns/call
312 $self->_die("Expected hash in 'mapping'");
313 }
314223µs if (!defined $data) {
315 $self->_error("Undefined data, expected mapping");
316 return;
317 }
3182237µs229µs if (!UNIVERSAL::isa($data, 'HASH')) {
# spent 9µs making 22 calls to UNIVERSAL::isa, avg 414ns/call
319 $self->_error("Non-valid data " . $data . ", expected mapping");
320 return;
321 }
322
3232258µs44403µs return if ($self->{done}{overload::StrVal($data)}{overload::StrVal($schema)});
# spent 403µs making 44 calls to overload::AddrRef, avg 9µs/call
3242267µs44376µs $self->{done}{overload::StrVal($data)}{overload::StrVal($schema)} = 1;
# spent 376µs making 44 calls to overload::AddrRef, avg 9µs/call
325
326223µs my %seen_key;
327223µs my $default_key_schema;
328
329 ## Originally this was an each-loop, but this could lead into
330 ## endless recursions, because mapping may be reused in Kwalify,
331 ## thus the each iterator was shared between recursion levels.
332 # while(my($key,$subschema) = each %$mapping) {
3332225µs for my $key (keys %$mapping) {
3346619µs my $subschema = $mapping->{$key};
3356614µs if ($key eq '=') { # the "default" key
336 $default_key_schema = $subschema;
337 next;
338 }
3396674µs66213µs my $subpath = _append_path($path, $key);
# spent 213µs making 66 calls to Kwalify::Validator::_append_path, avg 3µs/call
3406622µs $self->{path} = $subpath;
34166118µs6635µs if (!UNIVERSAL::isa($subschema, 'HASH')) {
# spent 35µs making 66 calls to UNIVERSAL::isa, avg 529ns/call
342 $self->_die("Expected subschema (a hash)");
343 }
3446677µs66236µs my $required = _get_boolean($subschema->{required});
# spent 236µs making 66 calls to Kwalify::Validator::_get_boolean, avg 4µs/call
3456619µs if (!exists $data->{$key}) {
346 if ($required) {
347 $self->{path} = $path;
348 $self->_error("Expected required key '$key'");
349 next;
350 } else {
351 next;
352 }
353 }
3546699µs6682µs my $unique = _get_boolean($subschema->{unique});
# spent 82µs making 66 calls to Kwalify::Validator::_get_boolean, avg 1µs/call
355668µs if ($unique) {
356 if (defined $unique_mapping_val->{$data->{$key}}->{val}
357 && $unique_mapping_val->{$data->{$key}}->{val} eq $data->{$key}) {
358 $self->_error("'$data->{$key}' is already used at '$unique_mapping_val->{$data->{$key}}->{path}'");
359 } else {
360 $unique_mapping_val->{$data->{$key}} = { val => $data->{$key},
361 path => $subpath,
362 };
363 }
364 }
365
3666687µs660s $self->_validate($subschema, $data->{$key}, $subpath);
# spent 1.41ms making 66 calls to Kwalify::Validator::_validate, avg 21µs/call, recursion: max depth 2, sum of overlapping time 1.41ms
3676661µs $seen_key{$key}++;
368 }
369
370# while(my($key,$val) = each %$data) {
3712265µs for my $key (keys %$data) {
3726621µs my $val = $data->{$key};
3736662µs66188µs my $subpath = _append_path($path, $key);
# spent 188µs making 66 calls to Kwalify::Validator::_append_path, avg 3µs/call
3746618µs $self->{path} = $subpath;
3756635µs if (!$seen_key{$key}) {
376 if ($default_key_schema) {
377 $self->_validate($default_key_schema, $val, $subpath);
378 } else {
379 $self->_error("Unexpected key '$key'");
380 }
381 }
382 }
383}
384
385sub _die {
386 my($self, $msg) = @_;
387 $msg = "[$self->{path}] $msg";
388 die $msg."\n";
389}
390
391sub _error {
392 my($self, $msg) = @_;
393 $msg = "[$self->{path}] $msg";
394 push @{$self->{errors}}, $msg;
395 0;
396}
397
398# Functions:
399
# spent 475µs (429+46) within Kwalify::Validator::_append_path which was called 154 times, avg 3µs/call: # 66 times (194µs+19µs) by Kwalify::Validator::validate_map at line 339, avg 3µs/call # 66 times (172µs+16µs) by Kwalify::Validator::validate_map at line 373, avg 3µs/call # 22 times (63µs+10µs) by Kwalify::Validator::validate_seq at line 288, avg 3µs/call
sub _append_path {
40015458µs my($root, $leaf) = @_;
401154514µs15446µs $root . ($root !~ m{/$} ? "/" : "") . $leaf;
# spent 46µs making 154 calls to Kwalify::Validator::CORE:match, avg 296ns/call
402}
403
404sub _base_path {
405 my($path) = @_;
406 my($base) = $path =~ m{([^/]+)$};
407 $base;
408}
409
410
# spent 321µs (241+80) within Kwalify::Validator::_get_boolean which was called 133 times, avg 2µs/call: # 66 times (155µs+80µs) by Kwalify::Validator::validate_map at line 344, avg 4µs/call # 66 times (82µs+0s) by Kwalify::Validator::validate_map at line 354, avg 1µs/call # once (3µs+0s) by Kwalify::Validator::validate_seq at line 283
sub _get_boolean {
41113350µs my($val) = @_;
412133366µs6680µs defined $val && $val =~ m{^(yes|true|1)$}; # XXX check for all boolean trues
# spent 80µs making 66 calls to Kwalify::Validator::CORE:match, avg 1µs/call
413}
414
41514µs1;
416__END__
 
# spent 288µs within Kwalify::Validator::CORE:match which was called 396 times, avg 727ns/call: # 154 times (46µs+0s) by Kwalify::Validator::_append_path at line 401, avg 296ns/call # 132 times (130µs+0s) by Kwalify::Validator::_additional_rules at line 82, avg 987ns/call # 66 times (80µs+0s) by Kwalify::Validator::_get_boolean at line 412, avg 1µs/call # 44 times (32µs+0s) by Kwalify::Validator::validate_str at line 193, avg 725ns/call
sub Kwalify::Validator::CORE:match; # opcode