Example #1
0
 def test_timer(self):
     with tools.timer("foo"):
         pass
     with tools.timer("foo", ms=True):
         pass
     with tools.timer("foo", write_file="/tmp/__timertest__"):
         pass
Example #2
0
PY2 = sys.version_info[0] == 2

if not PY2:
    xrange = range


def mandel(xsize=80, ysize=20, max_iteration=50):
    chars = " .,~:;+*%@##"
    for pixy in xrange(ysize):
        y0 = (pixy / ysize) * 2 - 1
        row = ""
        for pixx in xrange(xsize):
            x0 = (pixx / xsize) * 3 - 2
            x = 0
            y = 0
            iteration = 0
            while (x * x + y * y < 4) and iteration < max_iteration:
                xtemp = x * x - y * y + x0
                y = 2 * x * y + y0
                x = xtemp
                iteration += 1
            row += chars[iteration % 10]
        print(row)


if __name__ == "__main__":
    from moya.tools import timer

    with timer("Calculate mandelbrot set in raw python"):
        mandel()
Example #3
0
from moya.run import get_callable_from_document

call = get_callable_from_document('mandel.xml', 'mandel')

from moya.tools import timer
with timer("Calculate mandelbrot set", write_file="mandeltimes.csv"):
    call()