Exemple #1
0
def main():
    light_switch = LightSwitch(None)

    print('ensuring that services are on to begin with...')
    light_switch.ensure_services('on', SERVICES)

    def benchmark():
        start = perf_counter()

        print('stopping services...')
        light_switch.ensure_services('off', SERVICES)

        print('restarting services...')
        light_switch.ensure_services('on', SERVICES)

        return perf_counter() - start

    sum_times = 0
    for i in range(1, NUM_REPEATS + 1):
        print('repetition #:{}'.format(i))
        sum_times = sum_times + benchmark()

    print('average time: {} seconds'.format(sum_times / NUM_REPEATS))
    print('total time: {} seconds'.format(sum_times))