Sequence traversal
Darrell
news at dorb.com
Thu Sep 23 14:20:11 EDT 1999
Added the array index version it came up with .125 and 10.375 sec.
def test3():
cnt=0
ml=min(len(l1),len(l2))
for x in xrange(ml):
if (l1[x],l2[x])== searchKey:
cnt=cnt+1
return cnt
maxLoop: 1
Found: 1
Time: 0.0940 <=== map
maxLoop: 1
Found: 1
Time: 0.1880 <=== cached map
maxLoop: 1
Found: 1
Time: 0.1250 <=== array index
**********
maxLoop: 100
Found: 1
Time: 5.7030
maxLoop: 100
Found: 1
Time: 0.0000
maxLoop: 100
Found: 1
Time: 10.3750 <== array index
#############################
Changed:
sz=1000000
maxLoop from 100 ==> 10
memory use 125meg
Running just test3 the array index test, memory use was 33meg
Just test2 the map+cache was about 90meg
Just test1 the basic map, memory usage was 71meg
############################
maxLoop: 1
Found: 1
Time: 2.6100
maxLoop: 1
Found: 1
Time: 6.3280
maxLoop: 1
Found: 1
Time: 3.4060
**********
maxLoop: 10
Found: 1
Time: 19.7190
maxLoop: 10
Found: 1
Time: 0.0620 <== REM: It built a cache when it took 6.328 sec, I think
that's fair.
maxLoop: 10
Found: 1
Time: 34.6550
--
--Darrell
More information about the Python-list
mailing list