Hi, It is hard to say anything about this without knowing a bit more about "do some work".
For example if "do some work" contains tight loops then adding and removing things from the function might affect alignment of loop headers and result in some performance boost. Debug version of v8 also supports --print-code flag which might be very instrumental in performance audit. Regards, Vyacheslav Egorov. On Tue, May 11, 2010 at 11:23 PM, Avital Oliver <[email protected]> wrote: > Good afternoon friends, > > In the process of trying to optimize our Javascript code running on > Chrome/v8cgi we have stumbled upon what seems like counter-intuitive > results. Basically, in certain cases we see that adding code to a function > makes it faster (specifically, we are adding a call to a function that does > very little work and then returns). Also, we see significant jumps in the > time it takes to run a function even when we make very minor changes to it. > > To illustrate, here is a schematic representation of our functions and > timings: > > function f1(x) { // this takes 80 microseconds > // do some work > } > > function f2(x) { // this takes 60 microseconds > assert(x !== 0); > // do some work (same work) > } > > function f3(x) { // this takes 80 microseconds > if (x === 0) > ufu(); > > // do some work (same as before) > } > > We're pretty confused. Could this be because of some optimizations done in > V8 based on the length of functions or any other similar thing? Is there > anything we can do to help us understand this? > > Thanks in advance, > Avital. > asana.com > > -- > v8-users mailing list > [email protected] > http://groups.google.com/group/v8-users -- v8-users mailing list [email protected] http://groups.google.com/group/v8-users
