文章预览
项目简介 安装 bun add mitata npm install mitata 建议 使用专用硬件来运行基准测试 在启用垃圾收集的情况下运行(例如 node --expose-gc ... ) 确保您的运行时启用了高分辨率计时器和其他相关选项/权限 快速入门 javascript import { run, bench, boxplot } from 'mitata' ; function fibonacci ( n ) { if (n < = 1 ) return n; return fibonacci(n - 1 ) + fibonacci(n - 2 ); } bench( 'fibonacci(40)' , () => fibonacci( 40 )); boxplot( () => { bench( 'new Array($size)' , function * ( state ) { const size = state.get( 'size' ); yield () => Array .from({ length : size }); }).range( 'size' , 1 , 1024 ); }); await run(); C++ 单头文件 # include "src/mitata.hpp" int fibonacci ( int n) { if (n < = 1 ) return n; return fibonacci(n - 1 ) + fibonacci(n - 2 ); } int main () { mitata::runner runner; runner.bench( "noop" , []() { }); runner.summary([ & ]() { runner.be
………………………………