#!/usr/bin/python3

import time, math
from gi.repository import GLib

iterations = 1000000

start = time.clock()
for i in range(iterations):
    ml = GLib.MainLoop()
    assert not ml.is_running()
    ml.get_context().iteration(False)
end = time.clock()
print('MainLoop/MainContext %i iterations: %f s' % (iterations, end - start))

def cb():
    pass

start = time.clock()
for i in range(iterations):
    s = GLib.Idle()
    s.set_callback(cb)
    s.attach()
    s.destroy()
end = time.clock()
print('Idle %i iterations: %f s' % (iterations, end - start))
