histogram.export()


将直方图序列化为 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:

键类型字段
0uint格式版本(当前为 2)
1uint最低可识别值
2uint最高可跟踪值
3uint有效数字
4uint总计数
5uint最小值
6uint最大值
7uint归一化索引偏移
8float64转换比率
9uint计数数组长度
10array增量编码稀疏计数 [delta, c, ...]
11mapEWMA 状态(禁用时省略)

任何标准的 CBOR 解码器都可以解析输出。

🌐 Any standard CBOR decoder can parse the output.