# Collection of code snippets by Arne Vajhøj 
# (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import time
import psyco

def ix(a):
    i = 0
    while i < len(a):
        if a[i] < 0:
            raise Exception("Ooops")
        i = i + 1

def it(a):
    for e in a:
        if e < 0:
            raise Exception("Ooops")

def mix(a, n):
    t1 = time.time()
    i = 0
    while i < n:
        ix(a)
        i = i + 1
    t2 = time.time()
    print (t2-t1)

def mit(a, n):
    t1 = time.time()
    i = 0
    while i < n:
        it(a)
        i = i + 1
    t2 = time.time()
    print (t2-t1)

a = [1, 2, 3]
mix(a, 1000000)
mit(a, 1000000)
a = []
mix(a, 1000000)
mit(a, 1000000)
psyco.full()
a = [1, 2, 3]
mix(a, 100000000)
mit(a, 100000000)
a = []
mix(a, 100000000)
mit(a, 100000000)
