Mercurial > pub > Impl
comparison _test/temp.pl @ 274:8d36073411b1
+Added AutoDispose class
*code cleanups
author | cin |
---|---|
date | Wed, 30 Jan 2013 03:30:28 +0400 |
parents | edf011437be8 |
children | f116cd9fe7d9 |
comparison
equal
deleted
inserted
replaced
273:ad93c9f4dd93 | 274:8d36073411b1 |
---|---|
1 #!/usr/bin/perl | 1 #!/usr/bin/perl |
2 use strict; | 2 use strict; |
3 | 3 |
4 use XML::Compile::Schema; | 4 { |
5 use XML::Compile::Util qw(pack_type pack_id); | 5 package Foo; |
6 use Data::Dumper; | 6 use IMPL::declare { |
7 base => [ | |
8 'IMPL::Object::Disposable' => undef | |
9 ] | |
10 }; | |
11 } | |
12 | |
7 use Time::HiRes qw(gettimeofday tv_interval); | 13 use Time::HiRes qw(gettimeofday tv_interval); |
8 | |
9 my $schema = XML::Compile::Schema->new('Resources/resources.xsd'); | |
10 | 14 |
11 $schema->printIndex(); | |
12 | 15 |
13 my $type = pack_type 'http://implab.org/schemas/resources', 'resources'; | 16 use IMPL::lang; |
14 my $reader = $schema->compile( | 17 use IMPL::require { |
15 READER => $type, | 18 AutoDispose => 'IMPL::Object::AutoDispose', |
16 xsi_type => { | 19 DBSchema => 'IMPL::SQL::Schema' |
17 pack_type('http://implab.org/schemas/resources','AbstractResult') => 'AUTO' | 20 }; |
18 } | 21 |
19 ); | 22 my $real = DBSchema->new( name => 'simple', version => 1); |
23 my $proxy = AutoDispose->new($real); | |
24 | |
25 print typeof($proxy),"\n"; | |
20 | 26 |
21 my $t = [gettimeofday]; | 27 my $t = [gettimeofday]; |
22 | 28 |
23 my $obj = $reader->('Resources/sample.xml'); | 29 for (1..1000000) { |
30 $proxy->name; | |
31 } | |
24 | 32 |
25 print "Parsing small Xml file: ",tv_interval($t,[gettimeofday]),"\n"; | 33 print "proxy: ",tv_interval($t,[gettimeofday]),"\n"; |
26 | 34 |
27 print Dumper( $obj ); | 35 $t = [gettimeofday]; |
36 | |
37 for (1..1000000) { | |
38 $real->name; | |
39 } | |
40 | |
41 print "real: ",tv_interval($t,[gettimeofday]),"\n"; | |
28 | 42 |
29 |