I wanted to test the performance impact of declaring vars, so I wrote this test case:
https://cdn.discordapp.com/attachments/245876940274139166/ 522943745876951045/unknown.png
and profiled it:
https://cdn.discordapp.com/attachments/245876940274139166/ 522943795034324992/unknown.png
I was puzzled:
- Unused variables are clearly not optimized out, but this is fine because a warning is emitted and it's up to the programmer to fix the issue;
- /client/verb/meme consumes the bulk of the Self CPU time, but it's doing nothing different than what /client/verb/epic is doing.
To dig further I devised another test case:
https://media.discordapp.net/attachments/245876940274139166/ 522950230610673668/unknown.png?width=896&height=398
and profiled it:
https://media.discordapp.net/attachments/245876940274139166/ 522950305046855698/unknown.png
To explain what's going on:
- I have 5 verbs that call 5 different procs in a loop a fixed amount of times
- The verbs and procs are ordered so that meme1 has the most number of vars and meme5 has no vars at all.
The profiler output shows that the CPU cost of the called procs is not correlated with the number of vars contained within.
Instead, the CPU cost of declaring variables is counted towards the CALLER of the proc.
So my questions:
- Why is this the case?
- Is this behavior exclusive to declaring and/or "cleaning up" proc variables?
- Is it a problem? Should it be changed?
ID:2416249
Dec 14 2018, 10:25 am
|
|
This is technically a bug that could be reported