| 1 | #! /usr/bin/env perl |
| 2 | |
| 3 | use strictscip-perl cpan Data-DPath 0.60 strict/; |
| 4 | use warningsscip-perl cpan Data-DPath 0.60 warnings/; |
| 5 | use Test::TAPv13scip-perl cpan Data-DPath 0.60 Test/TAPv13/ ":all"; |
| 6 | use Test::Morescip-perl cpan Data-DPath 0.60 Test/More/ tests => 3; |
| 7 | use Data::DPathscip-perl cpan Data-DPath 0.60 Data/DPath/ 'dpath'; |
| 8 | use Data::Dumperscip-perl cpan Data-DPath 0.60 Data/Dumper/; |
| 9 | use Benchmarkscip-perl cpan Data-DPath 0.60 Benchmark/ ':all', ':hireswallclock'; |
| 10 | use Devel::Sizescip-perl cpan Data-DPath 0.60 Devel/Size/ 'total_size'; |
| 11 | use TAP::DOMscip-perl cpan Data-DPath 0.60 TAP/DOM/; |
| 12 | |
| 13 | BEGIN { |
| 14 | use_okscip-perl cpan Data-DPath 0.60 main/use_ok().( 'Data::DPath' ); |
| 15 | } |
| 16 | |
| 17 | my $tap; |
| 18 | { |
| 19 | local $/scip-perl cpan Data-DPath 0.60 main/`$/`.; |
| 20 | openscip-perl cpan Data-DPath 0.60 main/open(). (TAP, "< xt/regexp-common.tap") or diescip-perl cpan Data-DPath 0.60 main/die(). "Cannot read xt/regexp-common.tap"; |
| 21 | $tap = <TAP>; |
| 22 | close TAP; |
| 23 | } |
| 24 | |
| 25 | local $Data::DPath::USE_SAFEscip-perl cpan Data-DPath 0.60 main/`$Data::DPath::USE_SAFE`.; |
| 26 | |
| 27 | my $path = '//is_has[ value & $TAP::DOM::HAS_TODO & $TAP::DOM::IS_ACTUAL_OK ]/..'; |
| 28 | #my $path = '//is_has[ print(((value & $TAP::DOM::IS_ACTUAL_OK) ? "1" : "0")."\n") ; value & $TAP::DOM::HAS_TODO & $TAP::DOM::IS_ACTUAL_OK ]/..'; |
| 29 | #my $path = qq|//is_has[ print(((value & $IS_ACTUAL_OK) ? "1" : "0")."\n") ; value & $HAS_TODO & $IS_ACTUAL_OK ]/..|; |
| 30 | #my $path = '//is_has[ print value."\n" ]/..'; |
| 31 | #my $expected = "2"; |
| 32 | |
| 33 | foreach my $usebitsets (0..1) { |
| 34 | my $huge_data = TAP::DOM->newscip-perl cpan Data-DPath 0.60 TAP/DOM/new().( tap => $tap, usebitsets => $usebitsets ); |
| 35 | |
| 36 | my $resultlist; |
| 37 | |
| 38 | diagscip-perl cpan Data-DPath 0.60 main/diag(). "Running benchmark. Can take some time ..."; |
| 39 | my $count = 1; |
| 40 | my $t = timeitscip-perl cpan Data-DPath 0.60 main/timeit(). ($count, sub { $resultlist = [ dpathscip-perl cpan Data-DPath 0.60 main/dpath().($path)->matchscip-perl cpan Data-DPath 0.60 main/match().($huge_data) ] }); |
| 41 | my $n = $t->[5]; |
| 42 | my $throughput = $n / $t->[0]; |
| 43 | diag Dumperscip-perl cpan Data-DPath 0.60 main/Dumper().($resultlist); |
| 44 | okscip-perl cpan Data-DPath 0.60 main/ok().(1, "benchmark -- usebitsets = $usebitsets"); |
| 45 | tap13_yamlscip-perl cpan Data-DPath 0.60 main/tap13_yaml().({ benchmark => { |
| 46 | timestr => timestrscip-perl cpan Data-DPath 0.60 main/timestr().($t), |
| 47 | wallclock => $t->[0], |
| 48 | usr => $t->[1], |
| 49 | sys => $t->[2], |
| 50 | throughput => $throughput, |
| 51 | } |
| 52 | }); |
| 53 | } |
| 54 | |
| 55 | done_testing; |