File: huge-python.e

package info (click to toggle)
entity 1.0.1-8
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 5,604 kB
  • ctags: 5,394
  • sloc: ansic: 64,242; sh: 7,377; makefile: 776; perl: 319
file content (38 lines) | stat: -rw-r--r-- 716 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
#!/usr/bin/env entity

<object>
  
  <timer name="foo" interval="2000" action="python:search"/>
  <?python

import time
import sys

numnodes = 10000

print "creating", numnodes, "node tree:"

start_time = time.time ()

ob = enode ("object")
ob.attrib ( {"foo": "goo"} );

i = 0
while i < numnodes:
	node = ob.new_child ("fooey")
	if not (i % 2):
		node.attrib ( {"foo": "goo" })
	i = i + 1

totaltime = time.time() - start_time
print "done: ", totaltime, "\n"
    
def search(node):
	print "searching", numnodes, "node tree: "
	start_time =  time.time ()
	list = enode("object").children_attrib ("foo", "goo")
	totaltime = time.time() - start_time
	print "found", len(list), "nodes: ", totaltime, "\n"
?>

</object>