Mercurial > pub > Impl
diff _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 |
line wrap: on
line diff
--- a/_test/temp.pl Mon Aug 06 17:27:47 2012 +0400 +++ b/_test/temp.pl Sun Aug 19 22:27:43 2012 +0400 @@ -1,46 +1,24 @@ #!/usr/bin/perl use strict; +use XML::Compile::Schema; +use XML::Compile::Util qw(pack_type); +use Data::Dumper; use Time::HiRes qw(gettimeofday tv_interval); - -my $obj = {}; -my @vals = qw(a b c d e f g h i j k); -my @names = qw(one two three four five six); - -sub CreateMethod { - my ($dt) = @_; - $obj->{one} = $vals[1]; - $obj->{two} = $vals[2]; - $obj->{three} = $vals[3]; - $obj->{four} = $vals[4]; - $obj->{five} = $vals[5]; - $obj->{six} = $vals[6]; -} +my $schema = XML::Compile::Schema->new('Resources/person.xsd'); + +$schema->printIndex(); -my @pairs = map { [$names[$_],$_] } (1 .. $#names); +my $type = pack_type 'http://implab.org/person/', 'personInfo'; +my $reader = $schema->compile(READER => $type); -sub CreateMethodEval { - my ($dt) = @_; - my $i = 0; - map $obj->{$_} = $vals[$i++], @names; -} - my $t = [gettimeofday]; - - -CreateMethod($_) foreach (1..1000000); +my $obj = $reader->('Resources/person_info.xml'); -print "Build: ",tv_interval($t,[gettimeofday]),"\n"; - -$t = [gettimeofday]; +print "Parsing small Xml file: ",tv_interval($t,[gettimeofday]),"\n"; -CreateMethodEval($_) foreach (1..1000000); - -print "Eval: ",tv_interval($t,[gettimeofday]),"\n"; - -use URI::Escape; - -print uri_escape("/child///&?"), "\n"; - +print Dumper( $obj ); + +