The timings are for around 10 calls. I'm sure its the same function. I rewrote the code so that apply or call are not required, though when I place them in there it slows down a lot. I'm not sure what you mean with the .foo? I have printed both "this"-es and they are the same with and without. The reason I needed the apply in the first place was that the methods were in a seperate object:
Agent has a number of functions and properties.. not necessarily huge, though shouldnt apply mearly change a pointer to the this object? The callback function contains a reference to the agent as well:
var callback = function (data) {agent._send(message.origin, data, agentId, message.content.id);};
If I empty the callback
var callback = function (data) {};
the difference in execution speed drops dramatically. Does apply or call copy the arguments including their references somehow?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The timings are for around 10 calls. I'm sure its the same function. I rewrote the code so that apply or call are not required, though when I place them in there it slows down a lot. I'm not sure what you mean with the .foo? I have printed both "this"-es and they are the same with and without. The reason I needed the apply in the first place was that the methods were in a seperate object:
Agent has a number of functions and properties.. not necessarily huge, though shouldnt apply mearly change a pointer to the this object? The callback function contains a reference to the agent as well:
If I empty the callback
the difference in execution speed drops dramatically. Does apply or call copy the arguments including their references somehow?