Created
June 28, 2025 16:45
-
-
Save aquapi/0ea995416b86c850088330107317be31 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { summary, bench, run, do_not_optimize } from 'mitata'; | |
| bench('noop', () => { }); | |
| bench('noop', () => { }); | |
| bench('noop', () => { }); | |
| summary(() => { | |
| { | |
| const fn = (a: number, b: number) => a * 2 + b + Math.random(); | |
| do_not_optimize(fn); | |
| bench('Arrow', function* () { | |
| yield { | |
| [0]: Math.random, | |
| [1]: Math.random, | |
| bench: (a: number, b: number) => { | |
| do_not_optimize(fn(a, b)); | |
| } | |
| } | |
| }); | |
| } | |
| { | |
| function fn(a: number, b: number) { return a * 2 + b + Math.random(); } | |
| do_not_optimize(fn); | |
| bench('Func', function* () { | |
| yield { | |
| [0]: Math.random, | |
| [1]: Math.random, | |
| bench: (a: number, b: number) => { | |
| do_not_optimize(fn(a, b)); | |
| } | |
| } | |
| }); | |
| } | |
| }); | |
| summary(() => { | |
| { | |
| function fn(a: number, b: number) { return a * 2 + b + Math.random(); } | |
| do_not_optimize(fn); | |
| bench('Func', function* () { | |
| yield { | |
| [0]: Math.random, | |
| [1]: Math.random, | |
| bench: (a: number, b: number) => { | |
| do_not_optimize(fn(a, b)); | |
| } | |
| } | |
| }); | |
| } | |
| { | |
| const fn = (a: number, b: number) => a * 2 + b + Math.random(); | |
| do_not_optimize(fn); | |
| bench('Arrow', function* () { | |
| yield { | |
| [0]: Math.random, | |
| [1]: Math.random, | |
| bench: (a: number, b: number) => { | |
| do_not_optimize(fn(a, b)); | |
| } | |
| } | |
| }); | |
| } | |
| }); | |
| run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment