context.record(sample)


  • sample <Object>
    • operations <number> 已完成操作的数量。必须是一个正的安全整数。
    • duration_ns <bigint> 外部测量的正持续时间,以纳秒为单位,不超过 Number.MAX_SAFE_INTEGER。
    • detail <any> 额外的可结构化克隆示例数据。使用 CLI 进程隔离时,它还必须支持高级子进程序列化。
  • 返回:<Object> 归一化样本,包括它计算出的 rate 和可选的克隆 detail。

记录由另一个时钟或执行环境进行的测量。当一个高级工具在工作线程中测量工作并且需要排除消息传输时间时,这很有用。在一个回调中,record() 与 start() 和 end() 互斥,并且必须恰好调用一次。

🌐 Records a measurement made by another clock or execution environment. This is useful when a higher-level tool measures work in a worker and needs to exclude message transport from the duration. record() is mutually exclusive with start() and end() within one callback and must be called exactly once.