While implementing ‘friendly error when user overwrites p5.js functions’ discussed in this issue,
code for this lies here
Everything works fine and FES is functioning well.
But, there seems to be a big performance tradeoff by taking this approach.
There seems to be a benchmark test to test the performance of FES here
The times when run were as follows,
FES disabled : 115ms
FES enabled, with this approach : around 280ms
FES enabled, but without using getters and setters : around 120ms
this may not seem like a huge deal, but see the difference between enabling and disabling the FES, it’s only 5ms. all the other workload is only from one simple functionality.
We can overcome this problem by 2 ways:
- We can simply set all the p5.js functions to be unwritable, so no setters required. But, by taking this approach we cannot let the user to use the p5 function’s name as variables, which may not be favoured.
- We should use another approach to reach the same functionality but without using any getters or setters. They are just like attaching a huge number of event listeners imo.
I am trying to solve this problem for the last couple of days but found nothing useful. Hope the community helps.