# 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 timer.start_interval("Load texture with PIL") for i in range(500): im = open(filepath) ix, iy, image = 0, 0, None try: ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBA", 0, -1) except SystemError: ix, iy, image = im.size[0], im.size[1], im.tostring("raw", "RGBX", 0, -1) 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)
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): if ss.startswith("Teamto"): continue timer.stop_interval("startswith method")