-
Notifications
You must be signed in to change notification settings - Fork 43
Description
Hi, I am hitting a bit of a performance barrier using this library.
Using the sf.VertexArray I have done some quick and dirty benchmarks:
with N = 5000
sf.VertexArray of size N: ~15ms for a single window.draw() call
list of N sf.CircleShape objects: ~14ms for N window.draw() calls (for loop)
If I increase N, the time taken increases much faster for the list of CircleShapes as expected. For the vertex array the increase is marginal for up to N=50000. Great news!
Only problem is this weird baseline ~15ms that is used regardless. With any application we only have 16.7ms to maintain a constant 60 fps which leaves us with no budget for anything other than drawing. Given the VertexArray is really the only goto for batch-like drawing this poses a serious problem.
Is there some sort of workaround for this issue?
My quick (and very dirty) test:
from sfml import sf
import time
N = 5000
vertex_array = sf.VertexArray(sf.PrimitiveType.POINTS, N)
shape_list = [sf.CircleShape(5.0) for i in range(N)]
window = sf.RenderWindow(sf.VideoMode(1366, 768), "Benchmark Window")#, sf.Style.FULLSCREEN)
window.clear()
time.sleep(0.3)
time_initial = time.time()
window.draw(vertex_array)
time_va = time.time()
for shape in shape_list:
window.draw(shape)
time_sa = time.time()
elapsedA = (time_va - time_initial)*1000.0
elapsedB = (time_sa - time_va)*1000.0
print("VertexArray: %f" % elapsedA, flush=True)
print("list of shapes: %f" % elapsedB, flush=True)