# Complete refresh rate cycle done in miliseconds

**URL:** <https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341>\
**Category:** Coding\
**Tags:** timing\
**Created:** [April 8, 2019, 8:25pm UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341 "2019-04-08T20:25:53Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![niclai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/niclai/32/4405_2.png) [@niclai](https://discourse.psychopy.org/u/niclai)\
**Post date:** [April 8, 2019, 8:25pm UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341/1 "2019-04-08T20:25:53Z")

</div>

The refresh rate of my laptop’s monitor is 60Hz (running ‘’‘xrandr’’’ on the terminal), however, 60 iterations using win.flip() are done in ~ 0.04 seconds. I’m using a Dell 15 N5110 laptop running Ubuntu 16.04. The GPU is an NVIDIA GeForce GT 525M/PCIe/SSE2. Python 2.7.16 and Psychopy 3.0.7.

Unchecking ‘Sync to Vblank’ on NVIDIA X SERVER Settings does not solve the problem. Adding waitBlanking=False to the Window() call neither.

The final getTime() of the following code outputs around 0.04.

```auto
from psychopy.core import Clock
from psychopy.visual import Window

win = Window()

timer = Clock()
for frameN in range(60):
    win.flip()
    print 'Frame: ' + str(frameN)
    print 'Time: ' + str(timer.getTime())
    
print 'Final time: ' + str(timer.getTime())

```

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [April 9, 2019, 12:03am UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341/2 "2019-04-09T00:03:07Z")

</div>

And that is with the `print()` statements slowing everything down… it would presumably be even faster if you were storing these values in memory or using logging commands.

I guess this is the perennial issues of graphics driver support on Linux.  
What are the results of running PsychoPy’s benchmark wizard and the `timeByFrames.py` demo?

---

<div class="post-metadata">

**Author:** ![niclai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/niclai/32/4405_2.png) [@niclai](https://discourse.psychopy.org/u/niclai)\
**Post date:** [April 9, 2019, 7:11am UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341/3 "2019-04-09T07:11:36Z")

</div>

Here’s the output:

 ![timebyframe](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/f/bf3dcfc04b059ecc6d34e46f3c0bd775608cb0de.png)

Console output:  
‘’’  
pygame 1.9.5

Hello from the pygame community. [Contribute - pygame wiki](https://www.pygame.org/contribute.html)

**main** :19: UserWarning:

This call to matplotlib.use() has no effect because the backend has already

been chosen; matplotlib.use() must be called _before_ pylab, matplotlib.pyplot,

or matplotlib.backends is imported for the first time.

The backend was _originally_ set to ‘module://ipykernel.pylab.backend\_inline’ by the following code:

File "/home/nic/anaconda3/envs/py27/lib/python2.7/runpy.py", line 174, in \_run\_module\_as\_main

" **main**", fname, loader, pkg\_name)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/runpy.py", line 72, in \_run\_code

exec code in run\_globals

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/spyder\_kernels/console/ **main**.py", line 11, in \<module\>

start.main()

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/spyder\_kernels/console/start.py", line 298, in main

kernel.initialize()

File "\</home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/decorator.pyc:decorator-gen-121\>", line 2, in initialize

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/traitlets/config/application.py", line 87, in catch\_config\_error

return method(app, \*args, \*\*kwargs)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/ipykernel/kernelapp.py", line 485, in initialize

self.init\_code()

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/shellapp.py", line 266, in init\_code

self.\_run\_exec\_lines()

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/shellapp.py", line 292, in \_run\_exec\_lines

self.shell.run\_cell(line, store\_history=False)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/ipykernel/zmqshell.py", line 537, in run\_cell

return super(ZMQInteractiveShell, self).run\_cell(\*args, \*\*kwargs)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/interactiveshell.py", line 2724, in run\_cell

self.events.trigger(‘post\_run\_cell’)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/events.py", line 74, in trigger

func(\*args, \*\*kwargs)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/ipykernel/pylab/backend\_inline.py", line 164, in configure\_once

activate\_matplotlib(backend)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/IPython/core/pylabtools.py", line 315, in activate\_matplotlib

matplotlib.pyplot.switch\_backend(backend)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/pyplot.py", line 231, in switch\_backend

matplotlib.use(newbackend, warn=False, force=True)

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/ **init**.py", line 1422, in use

reload(sys.modules[‘matplotlib.backends’])

File "/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/backends/ **init**.py", line 16, in \<module\>

line for line in traceback.format\_stack()

0.4625 WARNING Monitor specification not found. Creating a temporary one…  
0.4634 WARNING User requested fullscreen with size [1280 1024], but screen is actually [1366, 768]. Using actual size  
0.9447 WARNING t of last frame was 2.08ms (=1/481)  
0.9462 WARNING t of last frame was 1.49ms (=1/669)  
0.9476 WARNING t of last frame was 1.41ms (=1/711)  
0.9490 WARNING t of last frame was 1.41ms (=1/709)  
0.9505 WARNING Multiple dropped frames have occurred - I’ll stop bothering you about them!

/home/nic/anaconda3/envs/py27/lib/python2.7/site-packages/matplotlib/axes/\_axes.py:6571: UserWarning: The ‘normed’ kwarg is deprecated, and has been replaced by the ‘density’ kwarg.

warnings.warn("The ‘normed’ kwarg is deprecated, and has been "  
‘’’

---

<div class="post-metadata">

**Author:** ![Michael](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/michael/32/16_2.png) [@Michael](https://discourse.psychopy.org/u/Michael)\
**Post date:** [April 11, 2019, 4:58am UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341/4 "2019-04-11T04:58:53Z")

</div>

Unless your screen is running at \> 500 Hz, your graphics card is not successfully set to sync to the vertical blank. PsychoPy requires this to be set, and the window should be created with waitBlanking set to True (the default).

---

<div class="post-metadata">

**Author:** ![niclai](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/niclai/32/4405_2.png) [@niclai](https://discourse.psychopy.org/u/niclai)\
**Post date:** [August 1, 2019, 10:18am UTC](https://discourse.psychopy.org/t/complete-refresh-rate-cycle-done-in-miliseconds/7341/5 "2019-08-01T10:18:07Z")

</div>

So, I updated Ubuntu to the 18.04 version and the problem is apparently solved. Below is the output of **timeByFrames.py**.

 ![timesbyframe](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/b/1/b1451f2e7c4f51a477a30513a4f162e06af0266e.png)
