Skip to content

Instantly share code, notes, and snippets.

@TheMatt2
Created July 1, 2018 18:49
Show Gist options
  • Save TheMatt2/0c49bc8b4f883f171f04adeda89394d0 to your computer and use it in GitHub Desktop.
Save TheMatt2/0c49bc8b4f883f171f04adeda89394d0 to your computer and use it in GitHub Desktop.
A pygame test that looks at the behavior of the pygame.time.Clock.tick() function.
import time
import pygame
FPSCLOCK = pygame.time.Clock()
def test_time():
start = time.time()
for i in range(100000):
x = i + 5
FPSCLOCK.tick(60)
return 100000 / (time.time() - start)
def test_tick(tick = None):
stop = time.time() + 1
x = 0
while time.time() < stop:
x += 1
if tick is None:
FPSCLOCK.tick()
else:
FPSCLOCK.tick(tick)
return x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment