File: huge-perl.e

package info (click to toggle)
entity 0.7.2-6
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,352 kB
  • ctags: 5,272
  • sloc: ansic: 61,707; sh: 7,921; makefile: 732; perl: 399
file content (55 lines) | stat: -rwxr-xr-x 1,157 bytes parent folder | download | duplicates (3)
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>