我正在编写工具来解析和提取 cpuprofile
文件(保存配置文件报告时生成的文件)中的一些数据,但我在 self 和总时间计算的精度方面遇到了一些问题。因此,时间取决于字段 hitCount
的值,但是。当 hitCount
较小 (<300) 时,hitCount
和 Self time
之间的系数约为 1.033。但随着 hitCount
的增长,系数也会增长。
因此,当 hitCount=3585 时,k 为 1.057。当hitCount=7265时:k=1.066。
目前我使用 1.035 作为系数,我试图最大限度地减少样本数据的错误。但我对近似值不满意。我对 Chromium 代码库不熟悉,无法直接在源代码中弄清楚。
那么如何获得具有 hitCount 值的函数调用的 Self 时间?
最佳答案
基本上是:
sampleDuration = totalRecordingDuration / totalHitCount
nodeSelfTime = nodeHitCount * sampleDuration
关于google-chrome - 如何使用 Google Chrome 的 devtools 配置文件报告(cpuprofile 文件)计算自身时间和总时间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31888211/