File: large_tapdom.t

package info (click to toggle)
libdata-dpath-perl 0.60-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,328 kB
  • sloc: perl: 3,737; makefile: 2
file content (55 lines) | stat: -rw-r--r-- 1,798 bytes parent folder | download | duplicates (5)
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
54
55
#! /usr/bin/env perl

use strict;
use warnings;
use Test::TAPv13 ":all";
use Test::More tests => 3;
use Data::DPath 'dpath';
use Data::Dumper;
use Benchmark ':all', ':hireswallclock';
use Devel::Size 'total_size';
use TAP::DOM;

BEGIN {
        use_ok( 'Data::DPath' );
}

my $tap;
{
        local $/;
        open (TAP, "< xt/regexp-common.tap") or die "Cannot read xt/regexp-common.tap";
        $tap = <TAP>;
        close TAP;
}

local $Data::DPath::USE_SAFE;

my $path          = '//is_has[ value & $TAP::DOM::HAS_TODO & $TAP::DOM::IS_ACTUAL_OK ]/..';
#my $path          = '//is_has[ print(((value & $TAP::DOM::IS_ACTUAL_OK) ? "1" : "0")."\n") ; value & $TAP::DOM::HAS_TODO & $TAP::DOM::IS_ACTUAL_OK ]/..';
#my $path          = qq|//is_has[ print(((value & $IS_ACTUAL_OK) ? "1" : "0")."\n") ; value & $HAS_TODO & $IS_ACTUAL_OK ]/..|;
#my $path          = '//is_has[ print value."\n" ]/..';
#my $expected      = "2";

foreach my $usebitsets (0..1) {
        my $huge_data = TAP::DOM->new( tap => $tap, usebitsets => $usebitsets );

        my $resultlist;

        diag "Running benchmark. Can take some time ...";
        my $count = 1;
        my $t = timeit ($count, sub { $resultlist = [ dpath($path)->match($huge_data) ] });
        my $n = $t->[5];
        my $throughput = $n / $t->[0];
        diag Dumper($resultlist);
        ok(1, "benchmark -- usebitsets = $usebitsets");
        tap13_yaml({ benchmark => {
                                   timestr    => timestr($t),
                                   wallclock  => $t->[0],
                                   usr        => $t->[1],
                                   sys        => $t->[2],
                                   throughput => $throughput,
                                  }
                   });
}

done_testing;