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 entity
<object>
<timer interval="2000" action="search"/>
<?perl
sub showtime
{
$TIMEVAL_T = "LL";
my $thetime = pack($TIMEVAL_T, ());
syscall (&SYS_gettimeofday, $thetime, 0) != -1
or die "gettimeofday: $!";
my @ltime = unpack($TIMEVAL_T, $thetime);
return ("$ltime[0]" . "." . "$ltime[1]");
}
require 'sys/syscall.ph';
my $numnodes = 10000;
my $start = showtime();
print ("creating $numnodes node tree: ");
my $obj = enode ("object");
$obj->attrib ("foo" => "goo");
for (my $i = 0; $i < $numnodes; $i++) {
my $node = $obj->new_child ("fooey");
$node->attrib ("foo" => "goo") if (! ($i % 2));
}
print (showtime() - $start, " s\n");
sub search
{
my $st = showtime();
print ("\nsearching $numnodes node tree: ");
my @list = enode("object")->children_attrib ("foo", "goo");
print (showtime() - $st . " s\n");
my $num = @list;
print ("returned $num results.\n");
# foreach $node (@list) {
# print ("$node\n");
# }
#
# enode("object")->call ("entity:quit");
}
?>
</object>
|