histogram.export()
- 返回:<Uint8Array>
将直方图序列化为 CBOR 编码(RFC 8949)的 Uint8Array,适合传输或持久存储。该编码使用桶计数的增量稀疏表示,因此输出大小随着记录的不同值数量而变化,而不是总桶数。
🌐 Serializes the histogram to a CBOR-encoded (RFC 8949) Uint8Array
suitable for transmission or persistent storage. The encoding uses a
delta-encoded sparse representation of the bucket counts, so the output size
scales with the number of distinct recorded values rather than the total
bucket count.
输出包括所有直方图配置、桶数据以及 EWMA 状态(启用时)。可以使用 perf_hooks.importHistogram() 将其重建为新的直方图。
🌐 The output includes all histogram configuration, bucket data, and EWMA
state (when enabled). It can be reconstructed into a new histogram using
perf_hooks.importHistogram().
CBOR 的负载是一个带有整数键的映射:
🌐 The CBOR payload is a map with integer keys:
| 键 | 类型 | 字段 |
|---|---|---|
| 0 | uint | 格式版本(当前为 2) |
| 1 | uint | 最低可识别值 |
| 2 | uint | 最高可跟踪值 |
| 3 | uint | 有效数字 |
| 4 | uint | 总计数 |
| 5 | uint | 最小值 |
| 6 | uint | 最大值 |
| 7 | uint | 归一化索引偏移 |
| 8 | float64 | 转换比率 |
| 9 | uint | 计数数组长度 |
| 10 | array | 增量编码稀疏计数 [delta, c, ...] |
| 11 | map | EWMA 状态(禁用时省略) |
任何标准的 CBOR 解码器都可以解析输出。
🌐 Any standard CBOR decoder can parse the output.