File: benchmark.pl

package info (click to toggle)
libxml-hash-lx-perl 0.0603-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 408 kB
  • sloc: perl: 2,603; makefile: 5
file content (53 lines) | stat: -rw-r--r-- 993 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env perl

use lib::abs '../lib';
use XML::Hash::LX;
use XML::Hash;
use XML::Simple;
use XML::Twig;
use XML::Bare;
use Benchmark qw(:all);
use Data::Dumper;

my $xml_converter = XML::Hash->new();
#my $twig = XML::Twig->new();
my $xml = do 'xml.pl';
my $xh_hash = $xml_converter->fromXMLStringtoHash($xml);
my $lx_hash = xml2hash($xml);
my $xs_hash = XMLin($xml);

=for rem
cmpthese timethese 1000, {
	'Bare' => sub {
		my $root = XML::Bare->new( text => $xml )->parse;
	},
	'Hash' => sub {
		my $xml_hash = $xml_converter->fromXMLStringtoHash($xml);
	},
	'Twig' => sub {
		XML::Twig->new()->parse($xml);
	},
	'Simple' => sub {
		my $xml_hash = XMLin($xml);
	},
	'Hash::LX' => sub {
		my $xml_hash = xml2hash($xml);
	},
};
=for rem
=cut

#=for rem
cmpthese timethese 100, {
	'Hash' => sub {
		my $oxml = $xml_converter->fromHashtoXMLString($xh_hash);
	},
	'Simple' => sub {
		my $oxml = XMLout($xs_hash);
	},
	'Hash::LX' => sub {
		my $oxml = hash2xml($lx_hash);
	},
};
=for rem
=cut