clock.sleep inaccuracy
Hi all:
I have noticed that the function:"clock.sleep" is not accurate.
It presents the stimulus longer than I have asked it..
for example showing empty canvases for 20 seconds ends up with 21.6 -22 or more sec:
prepare:
FRAMES_PER_SEC = 30
FRAME_LEN_MILLIS = 1000.0 / FRAMES_PER_SEC
canvases = [canvas() for _ in range(20 * FRAMES_PER_SEC)]
run:
var.start_time = clock.time()
for c in canvases:
c.show()
clock.sleep(FRAME_LEN_MILLIS)
var.end_time = clock.time()
var.show_duration = var.end_time - var.start_time
print var.show_duration
Starting experiment as ExperimentProcess-2
openexp._canvas.psycho.init_display(): waitblanking = True
openexp._canvas.psycho.init_display(): monitor = testMonitor
openexp._canvas.psycho.init_display(): screen = 0
openexp.sampler._legacy.init_sound(): sampling freq = 48000, buffer size = 1024
experiment.run(): experiment started at Fri Apr 13 18:11:16 2018
experiment.run(): disabling garbage collection
21600.0996923
21627.8375385
experiment.run(): experiment finished at Fri Apr 13 18:12:12 2018
experiment.end(): enabling garbage collection
done
Gily
Comments
Hi Gily,
This happens because
Canvas.show()is (usually) a blocking function that waits until the next refresh is started and the display is actually shown. So this introduces some delay, which accumulates if you do it very often. So if you want to present manyCanvasobjects in a row, you need to take this into account.Cheers!
Sebastiaan
Check out SigmundAI.eu for our OpenSesame AI assistant!