Data-Seek reviews

cpanratings
 

RSS | Module Info | Add a review of Data-Seek

Data-Seek (0.03)

The "extremely fast and efficient" claim currently doesn't hold, as this module creates a *whole* flattened tree for *every* search operation.

A simple benchmark:

###
use Benchmark qw(timethese);
use Data::Seek;
use Data::DPath qw(dpath);
use JSON::Path;

my $data = { map { $_ => {map {$_=>[1..4]} 1..20} } "a".."z" };

timethese(-0.25, {

dseek => sub { $ds = Data::Seek->new(data=>$data); $ds->search("j.1.\@")->data },

dseek_cacheobj=>sub{ state $ds=Data::Seek->new(data=>$data); $ds->search("j.1.\@")->data },

dpath=>sub{ dpath("/j/1/*")->match($data) },

jpath=>sub{ JSON::Path->new(q[$.j.1.[*]])->values($data) },
});
###

###
Benchmark: running dpath, dseek, dseek_cacheobj, jpath for at least 0.25 CPU seconds...

dpath: 1 wallclock secs ( 0.27 usr + 0.00 sys = 0.27 CPU) @ 8292.59/s (n=2239)

(warning: too few iterations for a reliable count)

dseek: 1 wallclock secs ( 0.29 usr + 0.00 sys = 0.29 CPU) @ 37.93/s (n=11)

(warning: too few iterations for a reliable count)
dseek_cacheobj: 0 wallclock secs ( 0.33 usr + 0.00 sys = 0.33 CPU) @ 42.42/s (n=14)

(warning: too few iterations for a reliable count)

jpath: 0 wallclock secs ( 0.27 usr + 0.00 sys = 0.27 CPU) @ 11711.11/s (n=3162)

(warning: too few iterations for a reliable count)
###

Also: 1) the syntax is rather inconsistent: ':n' for array index access, but '.@' (instead of ':@') for grabbing all elements. 2) currently cannot select subtree (must always select leaf node).

As alternatives, I recommend the much simpler JSON::Path, or the more powerful Data::DPath.