Exemplo n.º 1
0
#!/usr/local/bin/python
import mytimer
#import mymodules.mytimer2 as mytimer

mytimer.start_timer()
lines = 0
for row in open("words"):
    lines += 1
    
mytimer.end_timer()
print "Number of lines:",lines

# Added for Exercise 11, should crash
mytimer.end_timer()

# Now handle the exception


print "We are all done"

Exemplo n.º 2
0
#!/usr/local/bin/python
import mytimer
#import mymodules.mytimer2 as mytimer
#import cProfile

#cProfile.run('mytimer.start_timer()', 'start.prof')

mytimer.start_timer()
lines = 0
for row in open ("words"):
    lines += 1
    
mytimer.end_timer()
print ("Number of lines:",lines)
Exemplo n.º 3
0
if __name__ == '__main__':

    mytimer.start_timer()

    stems = {}

    for row in open("words"):
        for count in range(1, len(row)):
            stem = row[0:count]
            if stem in stems:
                stems[stem] += 1
            else:
                stems[stem] = 1
            #print "stem:",stem,"value:<",stems[stem],">"

    mytimer.end_timer('Load')

    # Process the stems
    # Senarios:
    # a)   n worker processes
    # b)    2 worker processes n/2 stem sizes each
    # c)    2 worker processes using a queue

    mytimer.start_timer()
    n = 30
    queue = Queue()
    #for stem_size in range(2,n+1):

    proc1 = Process(target=stem_search, args=(stems, queue))
    proc2 = Process(target=stem_search, args=(stems, queue))
    proc1.start()
Exemplo n.º 4
0
if __name__ == '__main__':   

    mytimer.start_timer()

    stems = {}

    for row in open ("words"):
        for count in range(1,len(row)):
            stem = row[0:count]
            if stem in stems:
                stems[stem] += 1
            else:
                stems[stem] = 1
            #print "stem:",stem,"value:<",stems[stem],">"
       
    mytimer.end_timer('Load')        

    # Process the stems
    # Senarios:
    # a)   n worker processes
    # b)    2 worker processes 14 stem sizes each
    # c)    2 worker processes using a queue

    mytimer.start_timer()
    n = 30
    
    #for stem_size in range(2,n+1): 
    
    proc1 = Process(target=stem_search, args=(stems,2,int(n/2)+1))
    proc1.start()
    proc2 = Process(target=stem_search, args=(stems,int(n/2)+1,n+1))