NAME
PERLANCAR::Tree::Examples - Generate sample tree object
VERSION
This document describes version 1.0.6 of PERLANCAR::Tree::Examples (from Perl distribution PERLANCAR-Tree-Examples), released on 2016-04-14.
SYNOPSIS
use PERLANCAR::Tree::Examples qw(gen_sample_data);
my $tree = gen_sample_data(size => 'medium1');
DESCRIPTION
This distribution can generate sample tree objects of several size (depth + number of nodes) and implementation (hash-based nodes or array-based). I use these example trees for benchmarking or testing in several other distributions.
Overview of available sample data
size=tiny1, backend=hash
(Tree::Example::HashNode) {_parent=>undef,id=>1,level=>0} |-- (Tree::Example::HashNode::Sub1) {id=>2,level=>1} \-- (Tree::Example::HashNode::Sub1) {id=>3,level=>1}
size=tiny1, backend=array
(Tree::Example::ArrayNode) [1,0,undef,"<obj>","<obj>"] |-- (Tree::Example::ArrayNode::Sub1) [2,1,"<obj>"] \-- (Tree::Example::ArrayNode::Sub1) [3,1,"<obj>"]
size=small1, backend=hash
(Tree::Example::HashNode) {_parent=>undef,id=>1,level=>0} |-- (Tree::Example::HashNode::Sub1) {id=>2,level=>1} | \-- (Tree::Example::HashNode::Sub2) {id=>5,level=>2} | |-- (Tree::Example::HashNode::Sub3) {id=>7,level=>3} | |-- (Tree::Example::HashNode::Sub3) {id=>8,level=>3} | |-- (Tree::Example::HashNode::Sub3) {id=>9,level=>3} | | \-- (Tree::Example::HashNode::Sub4) {id=>15,level=>4} | \-- (Tree::Example::HashNode::Sub3) {id=>10,level=>3} |-- (Tree::Example::HashNode::Sub1) {id=>3,level=>1} \-- (Tree::Example::HashNode::Sub1) {id=>4,level=>1} \-- (Tree::Example::HashNode::Sub2) {id=>6,level=>2} |-- (Tree::Example::HashNode::Sub3) {id=>11,level=>3} |-- (Tree::Example::HashNode::Sub3) {id=>12,level=>3} | \-- (Tree::Example::HashNode::Sub4) {id=>16,level=>4} |-- (Tree::Example::HashNode::Sub3) {id=>13,level=>3} (... 1 more line(s) not shown ...)
size=small1, backend=array
(Tree::Example::ArrayNode) [1,0,undef,"<obj>","<obj>","<obj>"] |-- (Tree::Example::ArrayNode::Sub1) [2,1,"<obj>","<obj>"] | \-- (Tree::Example::ArrayNode::Sub2) [5,2,"<obj>","<obj>","<obj>","<obj>","<obj>"] | |-- (Tree::Example::ArrayNode::Sub3) [7,3,"<obj>"] | |-- (Tree::Example::ArrayNode::Sub3) [8,3,"<obj>"] | |-- (Tree::Example::ArrayNode::Sub3) [9,3,"<obj>","<obj>"] | | \-- (Tree::Example::ArrayNode::Sub4) [15,4,"<obj>"] | \-- (Tree::Example::ArrayNode::Sub3) [10,3,"<obj>"] |-- (Tree::Example::ArrayNode::Sub1) [3,1,"<obj>"] \-- (Tree::Example::ArrayNode::Sub1) [4,1,"<obj>","<obj>"] \-- (Tree::Example::ArrayNode::Sub2) [6,2,"<obj>","<obj>","<obj>","<obj>","<obj>"] |-- (Tree::Example::ArrayNode::Sub3) [11,3,"<obj>"] |-- (Tree::Example::ArrayNode::Sub3) [12,3,"<obj>","<obj>"] | \-- (Tree::Example::ArrayNode::Sub4) [16,4,"<obj>"] |-- (Tree::Example::ArrayNode::Sub3) [13,3,"<obj>"] (... 1 more line(s) not shown ...)
size=medium1, backend=hash
(Tree::Example::HashNode) {_parent=>undef,id=>1,level=>0} |-- (Tree::Example::HashNode::Sub1) {id=>2,level=>1} | |-- (Tree::Example::HashNode::Sub2) {id=>102,level=>2} | | |-- (Tree::Example::HashNode::Sub3) {id=>3102,level=>3} | | | |-- (Tree::Example::HashNode::Sub4) {id=>8102,level=>4} | | | \-- (Tree::Example::HashNode::Sub4) {id=>8103,level=>4} | | | \-- (Tree::Example::HashNode::Sub5) {id=>16102,level=>5} | | \-- (Tree::Example::HashNode::Sub3) {id=>3103,level=>3} | | \-- (Tree::Example::HashNode::Sub4) {id=>8104,level=>4} | |-- (Tree::Example::HashNode::Sub2) {id=>103,level=>2} | | \-- (Tree::Example::HashNode::Sub3) {id=>3104,level=>3} | | |-- (Tree::Example::HashNode::Sub4) {id=>8105,level=>4} | | | \-- (Tree::Example::HashNode::Sub5) {id=>16103,level=>5} | | | \-- (Tree::Example::HashNode::Sub6) {id=>19102,level=>6} | | \-- (Tree::Example::HashNode::Sub4) {id=>8106,level=>4} (... 20386 more line(s) not shown ...)
size=medium1, backend=array
(Tree::Example::ArrayNode) [1,0,undef,"<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>"] |-- (Tree::Example::ArrayNode::Sub1) [2,1,"<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>","<obj>"] | |-- (Tree::Example::ArrayNode::Sub2) [102,2,"<obj>","<obj>","<obj>"] | | |-- (Tree::Example::ArrayNode::Sub3) [3102,3,"<obj>","<obj>","<obj>"] | | | |-- (Tree::Example::ArrayNode::Sub4) [8102,4,"<obj>"] | | | \-- (Tree::Example::ArrayNode::Sub4) [8103,4,"<obj>","<obj>"] | | | \-- (Tree::Example::ArrayNode::Sub5) [16102,5,"<obj>"] | | \-- (Tree::Example::ArrayNode::Sub3) [3103,3,"<obj>","<obj>"] | | \-- (Tree::Example::ArrayNode::Sub4) [8104,4,"<obj>"] | |-- (Tree::Example::ArrayNode::Sub2) [103,2,"<obj>","<obj>"] | | \-- (Tree::Example::ArrayNode::Sub3) [3104,3,"<obj>","<obj>","<obj>"] | | |-- (Tree::Example::ArrayNode::Sub4) [8105,4,"<obj>","<obj>"] | | | \-- (Tree::Example::ArrayNode::Sub5) [16103,5,"<obj>","<obj>"] | | | \-- (Tree::Example::ArrayNode::Sub6) [19102,6,"<obj>"] | | \-- (Tree::Example::ArrayNode::Sub4) [8106,4,"<obj>"] (... 20386 more line(s) not shown ...)
FUNCTIONS
gen_sample_data(%args) -> obj
Generate sample tree object.
This function is not exported by default, but exportable.
Arguments ('*' denotes required arguments):
backend => str (default: "hash")
size* => str
Which tree to generate.
There are several predefined sizes to choose from.
tiny1
is a very tiny tree, with only depth of 2 and a total of 3 nodes, including root node.small1
is a small tree with depth of 4 and a total of 16 nodes, including root node.medium1
is a tree of depth 7 and ~20k nodes, which is about the size ofOrg::Document
tree generated when parsing mytodo.org
document circa early 2016 (~750kB, ~2900 todo items).
Return value: (obj)
HOMEPAGE
Please visit the project's homepage at https://metacpan.org/release/PERLANCAR-Tree-Examples.
SOURCE
Source repository is at https://github.com/perlancar/perl-PERLANCAR-Tree-Examples.
BUGS
Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=PERLANCAR-Tree-Examples
When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.
SEE ALSO
dump-perlancar-sample-tree (App::DumpPERLANCARSampleTree), a simple CLI to conveniently view the sample data.
AUTHOR
perlancar <perlancar@cpan.org>
COPYRIGHT AND LICENSE
This software is copyright (c) 2016 by perlancar@cpan.org.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.