D’après une idée de zetamap A benchmark to calculate speed of graphic methods.
# https://my.numworks.com/python/zetamap/kandinsky_benchmark from kandinsky import * from ion import keydown from time import monotonic from math import cos, sin, log10 def test(method, *args): func = getattr(kandinsky, method) values = [] for i in range(300): time_is = monotonic() func(*args) values.append(monotonic()-time_is) kandinsky.fill_rect(0, 0, 320, 220, "white") print(method, "speed:", sum(values)/len(values)*10**6, "μs") kandinsky.draw_string("Welcome to kandinsky speed test program", 5, 50) kandinsky.draw_string("Press a key to start test ...", 15, 70) wait_key() kandinsky.fill_rect(0, 0, 320, 220, "white") test("set_pixel", 10, 10, "black") print("100*100: ", end='') test("fill_rect", 10, 10, 100, 100, "black") print("1*1: ", end='') test("fill_rect", 10, 10, 1, 1, "black") test("draw_string", "test string", 10, 10) for i in range(300): kandinsky.set_pixel(10+i, 10, (cos(i)*1000, sin(i)*1000, log10(i+1)*1000)) values = [] for i in range(300): time_is = monotonic() kandinsky.get_pixel(10+i, 10) values.append(monotonic()-time_is) print("get_pixel speed:", sum(values)/len(values)*10**6, "μs") for i in range(300): time_is = monotonic() kandinsky.color((cos(i)*1000, sin(i)*1000, log10(i+1)*1000)) values.append(monotonic()-time_is) print("color speed:", sum(values)/len(values)*10**6, "μs") input(">>> ")