I'm not exactly sure what you're running, but I assume it's something like:
``` var global = some_object; for (let i = 0; i < ....; i++) { do_something(global) } ``` V8 will learn that "global" never changes, and will optimize the loop in which `do_something` will be inlined; specializing it on the "dynamic constant" global. it might go as far as eliminating all code in the loop and just running an empty loop for the remainder of the benchmark. Benchmarking is hard ;-) On Wed, Dec 21, 2022 at 10:07 AM Jeongho Nam <samchon.git...@gmail.com> wrote: > Hello, I'm developer of typia <https://github.com/samchon/typia> and > running a benchmark program about runtime validators. During the benchmark > development, I've experience amazing happen that, if I repeat same function > repeatedly with same parameter value, typia became relatively about 8x > times faster than slowest (class-validator). > > ------------------------------------------ > > - multiple validation: typia/benchmark/results/11th Gen Intel(R) > Core(TM) i5-1135G7 @ 2.40GHz at master · samchon/typia (github.com) > <https://github.com/samchon/typia/tree/master/benchmark/results/11th%20Gen%20Intel(R)%20Core(TM)%20i5-1135G7%20%40%202.40GHz> > - only one validation: Benchmark, consider over-fitting optimization · > Issue #427 · samchon/typia (github.com) > <https://github.com/samchon/typia/issues/427> > > *15,000x faster code, multiple validation* > for (const elem of data) // length is 4 to 100 > typia.is<ObjectSimple>(elem); > > *200,000x faster code, only one validation* > typia.is<ObjectSimple>(data); > > ------------------------------------------ > > After seeing such difference, I'm wonder whethering that v8 engine caches > returned value from a function or not. I can't sure what is the reason why. > Is it caused by costs of array iteration? Or caused caching optimization > from v8 engine? > > Anyone who can explain and teach me? Please inform me the reason. > > -- > -- > v8-users mailing list > v8-users@googlegroups.com > http://groups.google.com/group/v8-users > --- > You received this message because you are subscribed to the Google Groups > "v8-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to v8-users+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/v8-users/6034f4a3-9d9b-4a1e-bc0b-11f51c26754an%40googlegroups.com > <https://groups.google.com/d/msgid/v8-users/6034f4a3-9d9b-4a1e-bc0b-11f51c26754an%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users --- You received this message because you are subscribed to the Google Groups "v8-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to v8-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/v8-users/CANS-YRqTHGRsqfFrX3vvsb%3D-9pfARmmEeHFr7q%3DynzMRuZrGNQ%40mail.gmail.com.