comparison _test/temp.pl @ 215:77a9934a44af

sync, migrating to XML::Compile
author cin
date Sun, 19 Aug 2012 22:27:43 +0400
parents 6adaeb86945d
children c477f24f1980
comparison
equal deleted inserted replaced
214:4683002758aa 215:77a9934a44af
1 #!/usr/bin/perl 1 #!/usr/bin/perl
2 use strict; 2 use strict;
3 3
4 use XML::Compile::Schema;
5 use XML::Compile::Util qw(pack_type);
6 use Data::Dumper;
4 use Time::HiRes qw(gettimeofday tv_interval); 7 use Time::HiRes qw(gettimeofday tv_interval);
8
9 my $schema = XML::Compile::Schema->new('Resources/person.xsd');
5 10
6 my $obj = {}; 11 $schema->printIndex();
7 my @vals = qw(a b c d e f g h i j k);
8 my @names = qw(one two three four five six);
9 12
10 sub CreateMethod { 13 my $type = pack_type 'http://implab.org/person/', 'personInfo';
11 my ($dt) = @_; 14 my $reader = $schema->compile(READER => $type);
12
13 $obj->{one} = $vals[1];
14 $obj->{two} = $vals[2];
15 $obj->{three} = $vals[3];
16 $obj->{four} = $vals[4];
17 $obj->{five} = $vals[5];
18 $obj->{six} = $vals[6];
19 }
20 15
21 my @pairs = map { [$names[$_],$_] } (1 .. $#names);
22
23 sub CreateMethodEval {
24 my ($dt) = @_;
25 my $i = 0;
26 map $obj->{$_} = $vals[$i++], @names;
27 }
28
29 my $t = [gettimeofday]; 16 my $t = [gettimeofday];
30 17
18 my $obj = $reader->('Resources/person_info.xml');
31 19
20 print "Parsing small Xml file: ",tv_interval($t,[gettimeofday]),"\n";
32 21
33 CreateMethod($_) foreach (1..1000000); 22 print Dumper( $obj );
34 23
35 print "Build: ",tv_interval($t,[gettimeofday]),"\n"; 24
36
37 $t = [gettimeofday];
38
39 CreateMethodEval($_) foreach (1..1000000);
40
41 print "Eval: ",tv_interval($t,[gettimeofday]),"\n";
42
43 use URI::Escape;
44
45 print uri_escape("/child///&?"), "\n";
46