[DRAFT] GDExtension: Undeprecate array_ref and add dictionary_ref#119461
[DRAFT] GDExtension: Undeprecate array_ref and add dictionary_ref#119461dsnopek wants to merge 1 commit into
array_ref and add dictionary_ref#119461Conversation
Performance testusageAs a means to replace the Array referenced in the return value of a ClassMethodPtrCall. ie an exposed getter method. methodologyrun for 1000 frames. In each frame call a series of GDE methods (same method(s) repeated 25 times) in order to dereference and assign an array to an initialized TypePtr. Begin a stopwatch before the GDE methods were called, stop it after they are completely called. Assign the time in nanoseconds to an array. Two methods were used
Stopwatch has100 nanosecond precision. sub 100 it would report 0 using Godot release version 4.6 codetimer baselineaverage 17 average 18 array_ref
average 452 average 429 average 500 average 464 average 578 average 589 average 484 destroy createCreate1 is the builtin constructor from GetPtrConstructor(.ARRAY, 1) average 1348 average 1360 average 1300 average 1342 average 1348 average 1434 average 1410 short conclusionThis is a very rudimentary test which only looks at one use case. This does not look at a case where the source or destination is a null value. There are several checks to exit earlier from the = operator overload for those. On average array_ref is more than 2x faster. Taking the fastest times the difference is 4-6x. If there is no other direct equivalent via GDE interface I will be using array_ref for at least this use case. |
|
There are several problems with your measurement:
TLDR: you'd need to measure two end-to-end scenarios that do the same thing (e.g. fetch and assign an array). Btw, you can use ```odin tags for syntax highlighting 🙂 |
|
Thanks for the feedback! I even mentioned the early return in the conclusion 🤦
Only using Create1 causes a mem leak when the destination array is already initialized. What does godot-cpp and rust do differently? I do want to get this comparison right. |
What problem(s) does this PR solve?
Additional information
Marked as DRAFT for now, because I haven't had a chance to test this with godot-cpp yet, and I'm not 100% sure it's the solution we should persue