Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Supported by

canvas.show() is slow with psycho back-end and 'difficult' canvas

edited June 2016 in OpenSesame

Hi all,

Ran into some big delays for canvas.show() function when using psycho back-end with a 'difficult' canvas.

I tested this by copying the Listing 2 example and adding Canvas3 with many randomly positioned fixation dots inspired by Example 2 here.

# Prepare canvas 1 and 2
canvas1 = canvas(exp)
canvas1.text('This is the first canvas')
canvas2 = canvas(exp)
canvas2.text('This is the second canvas')
# Prepare canvas 3 (without auto_prepare=False)
from random import randint
canvas3 = canvas()
for i in range(1000):
        x = randint(0, canvas3.width)
        y = randint(0, canvas3.height)
        canvas3.fixdot(x, y)
# Show canvas 1
t1 = canvas1.show()
# Sleep for 95 ms to get a 100 ms delay
self.sleep(95)
# Show canvas 2
t2 = canvas2.show()
# Sleep for 95 ms to get a 100 ms delay
self.sleep(95)
# Show canvas 3
t3 = canvas3.show()
# The actual delay will be 100 ms, because stimulus
# preparation time is not included. This is good!
print 'Actual delay t2-t1: %s' % (t2-t1)
# Sadly not for the 'difficult' canvas3
print 'Actual delay t3-t2: %s' % (t3-t2)

Gives the expected output for the legacy and xpyriment back-ends, but a big delay for the 'difficult' canvas3 (t3-t2) using the psycho back-end:

psycho back-end:

Actual delay t2-t1: 100.428051515

Actual delay t3-t2: 385.974423159

legacy back-end:

Actual delay t2-t1: 96

Actual delay t3-t2: 96

xpyriment back-end:

Actual delay t2-t1: 100.0

Actual delay t3-t2: 100.0

Notes:

  • I used opensesame_3.0.7-py2.7-win32-3 on Win7 64 bit with a 60Hz monitor to test this
  • Because I do not use auto_prepare=False so preparing with xpyriment back-end takes long
  • opensesame_3.1.0a41-py2.7-win32-1 and opensesame_2.9.7-win32-1 have the same delays
  • The actual delays match with the delays I recorded with a high speed camera

Best,

Jarik

Comments

  • edited June 2016

    Hi Jarik,

    Thanks for this benchmark.

    This results from the fact the PsychoPy doesn't prepare canvases in the same way that the other back-ends do; it does create stimulus objects in advance, but they are rendered only at the moment that the canvas is shown (i.e. OpenSesame calls draw() and flip() at the same time). Rendering is pretty fast, so this is usually fine; but when you have 1000+ stimuli it becomes notably slow. So that's basically inherent to how PsychoPy works.

    To be fair to PsychoPy, if you use psychopy directly, you can control when you call draw() and flip(), and this gives you better control of the timing:

    from psychopy import visual
    
    t0 = clock.time()
    # Can take a long time, but doesn't update the display
    for i in range(1000):
        visual.Circle(win).draw()
    t1 = clock.time()
    # Updates the display almost instantaneously
    win.flip()
    t2 = clock.time()
    
    print('draw() time: %.2f ms' % (t1-t0))
    print('flip() time: %.2f ms' % (t2-t1))
    

    But you cannot, for example, prepare multiple canvases with many objects in advance, and then show them in rapid succession. For that legacy and xpyriment are better.

    Cheers!
    Sebastiaan

  • edited 9:32AM

    Hi Sebastiaan,

    Thank you! Crystal clear now!

    One minor thing is your example script prints seconds instead of milliseconds, so it should be:

    print('draw() time: %.2f s' % (.001 * (t1-t0)))
    print('flip() time: %.2f s' % (.001 * (t2-t1)))
    #OR
    print('draw() time: %.2f ms' % (t1-t0))
    print('flip() time: %.2f ms' % (t2-t1))
    

    Best,

    Jarik

Sign In or Register to comment.

agen judi bola , sportbook, casino, togel, number game, singapore, tangkas, basket, slot, poker, dominoqq, agen bola. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 50.000 ,- bonus cashback hingga 10% , diskon togel hingga 66% bisa bermain di android dan IOS kapanpun dan dimana pun. poker , bandarq , aduq, domino qq , dominobet. Semua permainan bisa dimainkan hanya dengan 1 ID. minimal deposit 10.000 ,- bonus turnover 0.5% dan bonus referral 20%. Bonus - bonus yang dihadirkan bisa terbilang cukup tinggi dan memuaskan, anda hanya perlu memasang pada situs yang memberikan bursa pasaran terbaik yaitu http://45.77.173.118/ Bola168. Situs penyedia segala jenis permainan poker online kini semakin banyak ditemukan di Internet, salah satunya TahunQQ merupakan situs Agen Judi Domino66 Dan BandarQ Terpercaya yang mampu memberikan banyak provit bagi bettornya. Permainan Yang Di Sediakan Dewi365 Juga sangat banyak Dan menarik dan Peluang untuk memenangkan Taruhan Judi online ini juga sangat mudah . Mainkan Segera Taruhan Sportbook anda bersama Agen Judi Bola Bersama Dewi365 Kemenangan Anda Berapa pun akan Terbayarkan. Tersedia 9 macam permainan seru yang bisa kamu mainkan hanya di dalam 1 ID saja. Permainan seru yang tersedia seperti Poker, Domino QQ Dan juga BandarQ Online. Semuanya tersedia lengkap hanya di ABGQQ. Situs ABGQQ sangat mudah dimenangkan, kamu juga akan mendapatkan mega bonus dan setiap pemain berhak mendapatkan cashback mingguan. ABGQQ juga telah diakui sebagai Bandar Domino Online yang menjamin sistem FAIR PLAY disetiap permainan yang bisa dimainkan dengan deposit minimal hanya Rp.25.000. DEWI365 adalah Bandar Judi Bola Terpercaya & resmi dan terpercaya di indonesia. Situs judi bola ini menyediakan fasilitas bagi anda untuk dapat bermain memainkan permainan judi bola. Didalam situs ini memiliki berbagai permainan taruhan bola terlengkap seperti Sbobet, yang membuat DEWI365 menjadi situs judi bola terbaik dan terpercaya di Indonesia. Tentunya sebagai situs yang bertugas sebagai Bandar Poker Online pastinya akan berusaha untuk menjaga semua informasi dan keamanan yang terdapat di POKERQQ13. Kotakqq adalah situs Judi Poker Online Terpercayayang menyediakan 9 jenis permainan sakong online, dominoqq, domino99, bandarq, bandar ceme, aduq, poker online, bandar poker, balak66, perang baccarat, dan capsa susun. Dengan minimal deposit withdraw 15.000 Anda sudah bisa memainkan semua permaina pkv games di situs kami. Jackpot besar,Win rate tinggi, Fair play, PKV Games