Esempio n. 1
0
def compare(code):
    # Calculate mean execution time and compare to "timer" function
    ppc.timer(code, setup='core, stim')
    print '\nclock baseline:', testUsingClock(
        code), 'ms'  # negligeble, therefore not used
def compare(code):
    # Calculate mean execution time and compare to "timer" function
    ppc.timer(code, setup='core, stim')
    print '\nclock baseline:', testUsingClock(code), 'ms'  # negligeble, therefore not used
Esempio n. 3
0
"""
Timing python code and psychopy using the handy ppc.timer() function.
It's used to identify bottlenecks in the script, especially the part
   within the flip()-loop.

Jonas Kristoffer Lindeløv, 2013. Revised in 2015.
"""

import ppc

# -------------------------
# TIMING BASIC PYTHON STUFF
# Basic stuff is very fast!
# -------------------------

ppc.timer('pass')  # should give something close to 0
ppc.timer('if 99 == 99: pass')
ppc.timer('if "a" == "a": pass')
ppc.timer(
    'if "abracadabra" == "abracadabra": pass')  # string length means nothing
ppc.timer('myVariable = 4 + 5 * 2 / 3')

# Putting stuff in __main__ and time them
three = 3
ppc.timer('4 + three', 'three')  # using a variable is slower

# -------------------------
# TIMING PSYCHOPY STUFF
#   * Initating stimuli is slow, > 10ms
#   * Setting properties is medium. 0.1 - 5 ms (slower for text)
#   * Drawing is fast
"""
Timing python code and psychopy using the handy ppc.timer() function.
It's used to identify bottlenecks in the script, especially the part
   within the flip()-loop.

Jonas Kristoffer Lindeløv, 2013. Revised in 2015.
"""

import ppc

# -------------------------
# TIMING BASIC PYTHON STUFF
# Basic stuff is very fast!
# -------------------------

ppc.timer('pass')  # should give something close to 0
ppc.timer('if 99 == 99: pass')
ppc.timer('if "a" == "a": pass')
ppc.timer('if "abracadabra" == "abracadabra": pass')  # string length means nothing
ppc.timer('myVariable = 4 + 5 * 2 / 3')

# Putting stuff in __main__ and time them
three = 3
ppc.timer('4 + three', 'three')  # using a variable is slower


# -------------------------
# TIMING PSYCHOPY STUFF
#   * Initating stimuli is slow, > 10ms
#   * Setting properties is medium. 0.1 - 5 ms (slower for text)
#   * Drawing is fast