I was trying to implement a sort of Priority Queue, in the code below you can see that when i put a element inside the queue i just sort my array.
I already knew that the performance would not be good but I've noticed that while the test is running my cpu usage reach only 25%.
I was expecting something like 90%.
Some one can explain why this is happening ?
I've run the test directly from the editor and these are the results:
Put_Sort of 100 elements: 28ms
Put_Sort of 200 elements: 120ms
Put_Sort of 300 elements: 298ms
Put_Sort of 400 elements: 565ms
Put_Sort of 500 elements: 924ms
Put_Sort of 600 elements: 1420ms
Put_Sort of 700 elements: 2000ms
Put_Sort of 800 elements: 2690ms
Put_Sort of 900 elements: 3416ms
Put_Sort of 1000 elements: 4365ms
My Test Code
queue = 
return v1 < v2
var pv = [[int(vect.x),int(vect.y)],int(priority)]
var vect = queue
for i in range(10):
var pq = PriorityQueue.new()
var ms = OS.get_ticks_msec()
for j in range(r):
pq.put(Vector2(j,j),randi() % 100)
print("Put_Sort of ",r," elements: ",OS.get_ticks_msec()-ms,"ms")
Thanks in advance for your help!