diff --git a/benchmarks/pygame_random_triangles.py b/benchmarks/pygame_random_triangles.py index 9c1d48e..4164ce8 100644 --- a/benchmarks/pygame_random_triangles.py +++ b/benchmarks/pygame_random_triangles.py @@ -2,6 +2,8 @@ import pygame import time import random +N_TRIANGLES = 1000 + def main(): pygame.init() @@ -21,7 +23,7 @@ def main(): surface.fill((0,0,0)) - for i in xrange(1000): + for i in xrange(N_TRIANGLES): p1 = (random.randint(0,512), random.randint(0, 512)) p2 = (random.randint(0,512), random.randint(0, 512)) p3 = (random.randint(0,512), random.randint(0, 512)) diff --git a/benchmarks/pyglet_random_triangles.py b/benchmarks/pyglet_random_triangles.py index 8893507..f606272 100644 --- a/benchmarks/pyglet_random_triangles.py +++ b/benchmarks/pyglet_random_triangles.py @@ -3,6 +3,8 @@ from pyglet.gl import * import random import time +N_TRIANGLES = 1000 + window = pyglet.window.Window() frames = 0 @@ -21,7 +23,7 @@ def on_draw(): window.clear() glClear(GL_COLOR_BUFFER_BIT) glLoadIdentity() - for x in range(1000): + for x in range(N_TRIANGLES): glColor3ub(random.randint(0,255), random.randint(0,255), random.randint(0,255)) glBegin(GL_LINE_LOOP) glVertex2f(random.randint(0,512), random.randint(0,512)) diff --git a/benchmarks/random_triangles b/benchmarks/random_triangles new file mode 100755 index 0000000..4497ab9 Binary files /dev/null and b/benchmarks/random_triangles differ diff --git a/benchmarks/random_triangles.c b/benchmarks/random_triangles.c index 3b82789..b455f85 100644 --- a/benchmarks/random_triangles.c +++ b/benchmarks/random_triangles.c @@ -1,6 +1,8 @@ #include "SDL/SDL.h" #include +#define N_TRIANGLES 1000 + int main(int argc, char **argv) { SDL_Init(SDL_INIT_EVERYTHING); @@ -37,7 +39,7 @@ int main(int argc, char **argv) { SDL_RenderClear(renderer); SDL_SetRenderDrawColor(renderer, 255, 0, 0, 255); - for(i=0; i < 20; ++i) { + for(i=0; i < N_TRIANGLES; ++i) { SDL_SetRenderDrawColor(renderer, rand()%255, rand()%255, rand()%255, 255); p1.x = rand()%512; p1.y = rand()%512; diff --git a/demo/random_triangles.py b/demo/random_triangles.py index d03a584..7e3de94 100755 --- a/demo/random_triangles.py +++ b/demo/random_triangles.py @@ -2,11 +2,13 @@ from demo_utils import simple_timed_loop import random +N_TRIANGLES = 1000 + def draw(window): window.renderer.set_draw_color(0,0,0,255) window.renderer.clear() window.renderer.set_draw_color(255,0,0,255) - for i in xrange(1000): + for i in xrange(N_TRIANGLES): window.renderer.set_draw_color(random.randint(0,255), random.randint(0,255), random.randint(0,255))