Exemple #1
0
def test_cached_read():
    "Read a file (and cache it)"
    import time
    #del(pyarbus.data._cache[short_test_file])
    tic = time.time()
    el = pyarbus.read_eyelink_cached(short_test_file)
    toc = time.time()
    total_time = toc - tic
    # Here, we add a dummy attribute to the object - it should still be there
    # after we re-read short_test_file from cache, since we're not modifying
    # the object that's stored in the cache.
    el.__extra_dummy = 10
    tic = time.time()
    el = pyarbus.read_eyelink_cached(short_test_file)
    # windows time.time is only ms resolution:
    # http://mail.python.org/pipermail/python-list/2007-January/1121263.html
    toc = time.time() + 0.001
    cached_time = toc - tic
    speedup = total_time / cached_time
    el.__extra_dummy  # should *not* raise an attribute error
    print("speedup = %.3fx" % speedup)
    # the speedup in general depends on the file size, disk speed, and how fast
    # we read it, etc, but for the file on this test, I see speedups of ~ 500x
    # on my machine, so I'm just putting a conservative speedup assertion of at
    # least 20x test in here for good measure. NOTE: this test might actually
    # fail if we write a much faster file reader, such that caching it is not
    # longer as much of a performance boost as it was before, but that' a nice
    # bug to have. Also, for test this small, pyarbus.data.log.level
    # actually makes a big difference in the speedup, since printing to stderr
    # and capturing that output has overhead for nose.
    assert (speedup > 20.)
    # remove it from the cache
    del (pyarbus.data._cache[short_test_file])
Exemple #2
0
def test_cached_read():
    "Read a file (and cache it)"
    import time
    #del(pyarbus.data._cache[short_test_file])
    tic = time.time()
    el = pyarbus.read_eyelink_cached(short_test_file)
    toc = time.time()
    total_time = toc - tic
    # Here, we add a dummy attribute to the object - it should still be there
    # after we re-read short_test_file from cache, since we're not modifying
    # the object that's stored in the cache.
    el.__extra_dummy = 10
    tic = time.time()
    el = pyarbus.read_eyelink_cached(short_test_file)
    # windows time.time is only ms resolution:
    # http://mail.python.org/pipermail/python-list/2007-January/1121263.html
    toc = time.time() + 0.001
    cached_time = toc-tic
    speedup = total_time / cached_time
    el.__extra_dummy # should *not* raise an attribute error
    print("speedup = %.3fx" % speedup)
    # the speedup in general depends on the file size, disk speed, and how fast
    # we read it, etc, but for the file on this test, I see speedups of ~ 500x
    # on my machine, so I'm just putting a conservative speedup assertion of at
    # least 20x test in here for good measure. NOTE: this test might actually
    # fail if we write a much faster file reader, such that caching it is not
    # longer as much of a performance boost as it was before, but that' a nice
    # bug to have. Also, for test this small, pyarbus.data.log.level
    # actually makes a big difference in the speedup, since printing to stderr
    # and capturing that output has overhead for nose.
    assert(speedup > 20.)
    # remove it from the cache
    del(pyarbus.data._cache[short_test_file])
Exemple #3
0
def test_eyelink_to_plot_xyp():
    "Give useful feedback on common error for plot_xyp(el)"
    el = pyarbus.read_eyelink_cached(test_file)
    npt.assert_raises(ValueError, viz.plot_xyp, el)
Exemple #4
0
def test_saccade_hist():
    "Plotting of saccade histogram (polar coordinates)"
    el = pyarbus.read_eyelink_cached(test_file)
    viz.plot_saccade_hist(el.r.saccades)
    plt.show()
Exemple #5
0
def test_saccade_scatter():
    "Plotting of saccade scatter plot (polar coordinates)"
    el = pyarbus.read_eyelink_cached(test_file)
    viz.plot_saccade_scatter(el.r.saccades)
    plt.show()
Exemple #6
0
def test_eyelink_to_plot_xyp():
    "Give useful feedback on common error for plot_xyp(el)"
    el = pyarbus.read_eyelink_cached(test_file)
    npt.assert_raises(ValueError, viz.plot_xyp, el)
Exemple #7
0
def test_saccade_hist():
    "Plotting of saccade histogram (polar coordinates)"
    el = pyarbus.read_eyelink_cached(test_file)
    viz.plot_saccade_hist(el.r.saccades)
    plt.show()
Exemple #8
0
def test_saccade_scatter():
    "Plotting of saccade scatter plot (polar coordinates)"
    el = pyarbus.read_eyelink_cached(test_file)
    viz.plot_saccade_scatter(el.r.saccades)
    plt.show()