Source

blaag.haard.se / code / constants / benchmark.py

import random 

ONE = 1
TWO = "two"
THREE = 3
FOUR = 4.0


def costly(iterations):
    tempstr = ""
    obj = MyClass()
    for i in range(iterations):
        tempstr += ONE * TWO * THREE + str(i)
        obj.change()
    tempstr += str(obj.value)
    return tempstr

class MyClass(object):
    def __init__(self):
        self.value = random.random()*THREE

    def change(self):
        self.value += random.random()*FOUR