beforeEach(fn)


  • fn <Function> | <AsyncFunction> 这个钩子函数。它接收一个包含基准测试的 name、params 和 signal 的对象。

注册一个钩子,在当前套件中的每个完整的逻辑基准之前运行一次。它不会在每个样本之前运行。每个样本的设置应该放在基准函数中,在 context.start() 或 context.record() 之前。

🌐 Registers a hook that runs once before each complete logical benchmark in the current suite. It does not run before every sample. Per-sample setup belongs in the benchmark function before context.start() or context.record().