Calling aliases and performance

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,848
First Language
English
I saw some discussions related to performance and it was brought up that using the "call" method is slow.

This jsperf was also linked: https://jsperf.com/function-calls-direct-vs-apply-vs-call-vs-bind/18

However, when I ran it, it seems like call was the fastest method when I ran it in chrome.

Testing in Chrome 46.0.2490.86 32-bit on Windows Server 2008 / Vista 64-bit
I don't know if this is only because chrome is super fast or something, but is `call` really a problem?
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
That's definitely interesting, my results look like this:


jsperf.png


(Chrome performance is slower, because i'm currently watching Netflix on it :D )


It seems like Chrome doesn't actually make a difference between call() and a direct function call, but in Firefox it makes a big difference.
 
Last edited by a moderator:

Dr.Yami

。◕‿◕。
Developer
Joined
Mar 5, 2012
Messages
1,003
Reaction score
757
First Language
Vietnamese
Primarily Uses
Other
.call() is good and I don't see any problem with it. And it solves many problems about scopes in JS.
 

Tsukihime

Veteran
Veteran
Joined
Jun 30, 2012
Messages
8,564
Reaction score
3,848
First Language
English
That's definitely interesting, my results look like this:


jsperf.png


(Chrome performance is slower, because i'm currently watching Netflix on it :D )


It seems like Chrome doesn't actually make a difference between call() and a direct function call, but in Firefox it makes a big difference.
Oh ya, firefox just tanks in performance. 92% slower lol that's terrible...
 

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
doing .call and .apply is not slow. aliasing can become slow as you go from A -> B -> C -> D, assume that A is the parent function and B,C,D all alias it in separate scripts loading in sequential order. This will eventually lead to performance issues.

How ever if you really want the fastest way: use .apply(this, args) its not much faster but it a tad bit
 

Iavra

Veteran
Veteran
Joined
Apr 9, 2015
Messages
1,797
Reaction score
863
First Language
German
Primarily Uses
apply() has been a lot slower than call() in all of our tests, so i really doubt that.
 

Hudell

Dog Lord
Veteran
Joined
Oct 2, 2014
Messages
3,546
Reaction score
3,717
First Language
Java's Crypt
Primarily Uses
RMMZ
I thought .apply was the slowest option? It was when I ran that linked test.
 

Victor Sant

Veteran
Veteran
Joined
Mar 17, 2012
Messages
1,694
Reaction score
1,452
First Language
Portuguese
Primarily Uses
Like i said in your feed, there are some people that are "performance freak" that cries about every milesecond lost.

I can't say for sure if .call is slow or not since i'm inexperienced in js. But what can I say until now is that i had no noticeable performance loss, and by noticeable i mean something that i don't need a software to show me.

And as an alias abuser, i really hope this never happens :D
 
Last edited by a moderator:

DarknessFalls

Rpg Maker Jesus - JS Dev.
Veteran
Joined
Jun 7, 2013
Messages
1,393
Reaction score
210
First Language
English
.call method is not slow at all.
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Posts

Latest Profile Posts

Just beat the last of us 2 last night and starting jedi: fallen order right now, both use unreal engine & when I say i knew 80% of jedi's buttons right away because they were the same buttons as TLOU2 its ridiculous, even the same narrow hallway crawl and barely-made-it jump they do. Unreal Engine is just big budget RPG Maker the way they make games nearly identical at its core lol.
Can someone recommend some fun story-heavy RPGs to me? Coming up with good gameplay is a nightmare! I was thinking of making some gameplay platforming-based, but that doesn't work well in RPG form*. I also was thinking of removing battles, but that would be too much like OneShot. I don't even know how to make good puzzles!
one bad plugin combo later and one of my followers is moonwalking off the screen on his own... I didn't even more yet on the new map lol.
time for a new avatar :)

Forum statistics

Threads
106,017
Messages
1,018,356
Members
137,802
Latest member
rencarbali
Top