Branch: refs/heads/main
Home: https://github.com/WebKit/WebKit
Commit: 222d2e04c1d686c2294db4a68733d64da28825b3
https://github.com/WebKit/WebKit/commit/222d2e04c1d686c2294db4a68733d64da28825b3
Author: Yijia Huang <[email protected]>
Date: 2025-04-18 (Fri, 18 Apr 2025)
Changed paths:
M Source/WTF/WTF.xcodeproj/project.pbxproj
M Source/WTF/wtf/CMakeLists.txt
A Source/WTF/wtf/StatisticsManager.cpp
A Source/WTF/wtf/StatisticsManager.h
Log Message:
-----------
[WTF] Introduce StatisticsManager for recording per-key numeric statistics
with histogram support
https://bugs.webkit.org/show_bug.cgi?id=291647
rdar://149416894
Reviewed by Keith Miller.
This patch introduces `WTF::StatisticsManager`, a thread-safe singleton for
recording statistical metrics (e.g. count, min, max, mean, variance, standard
deviation) for arbitrary string identifiers.
Each identifier (e.g. "unrolled-loop-loopBodySize") accumulates the
full data history (Vector<double>) in time. And count, sum, sum-of-squares,
min, max, and histogram with 10 bins, computed on-demand during
dumpStatistics().
This supports runtime use cases such as performance profiling, optimization
validation, and internal monitoring.
Example usage:
StatisticsManager::singleton().addDataPoint("fully-unrolled-loop-loopBodySize",
loopSize);
...
StatisticsManager::singleton().addDataPoint("partially-unrolled-loop-loopBodySize",
loopSize);
...
StatisticsManager::singleton().dumpStatistics();
StatisticsManager::singleton().clear(); // optional
Output format:
Statistics for fully-unrolled-loop-loopBodySize:
Count : 34
Min : 22.000000
Max : 189.000000
Mean : 49.794118
Variance : 1487.045848
Std Dev : 38.562233
Histogram:
[22.00 - 38.70): 21
[38.70 - 55.40): 6
[55.40 - 72.10): 2
[72.10 - 88.80): 1
[88.80 - 105.50): 0
[105.50 - 122.20): 1
[122.20 - 138.90): 1
[138.90 - 155.60): 1
[155.60 - 172.30): 0
[172.30 - 189.00): 1
Statistics for partially-unrolled-loop-loopBodySize:
...
Future extensions may include percentile estimation, histogram range controls,
or scoped/statistical macros for easier instrumentation.
* Source/WTF/WTF.xcodeproj/project.pbxproj:
* Source/WTF/wtf/CMakeLists.txt:
* Source/WTF/wtf/StatisticsManager.cpp: Added.
(WTF::StatisticsManager::singleton):
(WTF::StatisticsManager::StatBucket::add):
(WTF::StatisticsManager::StatBucket::mean const):
(WTF::StatisticsManager::StatBucket::variance const):
(WTF::StatisticsManager::StatBucket::stdDev const):
(WTF::StatisticsManager::StatBucket::prepareHistogram):
(WTF::StatisticsManager::StatBucket::addToHistogram):
(WTF::StatisticsManager::StatBucket::dumpHistogram):
(WTF::StatisticsManager::addDataPoint):
(WTF::StatisticsManager::dumpStatistics):
(WTF::StatisticsManager::clear):
* Source/WTF/wtf/StatisticsManager.h: Added.
Canonical link: https://commits.webkit.org/293856@main
To unsubscribe from these emails, change your notification settings at
https://github.com/WebKit/WebKit/settings/notifications
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes