import pygame from PIL.Image import open from OpenGL.GL import * from Timer import Timer filepath = "../src/lena.jpg" timer = Timer() screen = pygame.display.set_mode((1280, 720), pygame.OPENGL | pygame.DOUBLEBUF) pygame.init() # Load images with Pygame timer.start_interval("Load texture with Pygame") for i in range(500): data = pygame.image.load(os.path.join("", filepath)) image = pygame.image.tostring(data, 'RGBA', 1) width, height = data.get_rect().size tex = glGenTextures(1) glBindTexture(GL_TEXTURE_2D, tex) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, image) glBindTexture(GL_TEXTURE_2D, 0) timer.stop_interval("Load texture with Pygame") # Load images with PIL
#Created on 27 june 2014 #@author bastien.laby from Timer import Timer timer = Timer() ss = "Teamto Hello" # # Test if a string contains a word # # IN statement timer.start_interval("in statement") for i in range(10000000): if "Teamto" in ss: continue timer.stop_interval("in statement") # __contains__ method timer.start_interval("contains method") for i in range(10000000): if ss.__contains__("Teamto"): continue timer.stop_interval("contains method") # startswith method timer.start_interval("startswith method") for i in range(10000000):