Created
November 14, 2015 19:58
benchmark key presses on from aenea client to server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aenea.wrappers import ensure_execution_context | |
from aenea import Key | |
import time | |
time.sleep(5) | |
# get context ahead of time so our timing is more accurate | |
DATA = ensure_execution_context({}) | |
def press_separate(): | |
action = Key('a-1') + Key('a-2') + Key('a-3') + Key('a-4') + Key('a-5') | |
action.execute(data=DATA) | |
def press_combined(): | |
action = Key('a-1,a-2,a-3,a-4,a-5') | |
action.execute(data=DATA) | |
def press_repeat(): | |
action = Key('a-1:5') | |
action.execute(data=DATA) | |
def bench(func, count=100): | |
t = time.time() | |
for _ in range(0, count): | |
func() | |
t = time.time() - t | |
return t / count | |
print 'running benchmarks...' | |
print 'press_separate execution time: %.4f' % bench(press_separate) | |
print 'press_combined execution time: %.4f' % bench(press_combined) | |
print 'press_repeat execution time: %.4f' % bench(press_repeat) | |
print 'done!' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment