Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(710)

Unified Diff: third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp

Issue 1978403004: Add UMA histograms for WebAudio (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address more review comments. Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
diff --git a/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp b/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
index dc3afb966c3be24c02b0a5c034ddb0727f8a75d7..9b0e0cd2411d6b7d2c679e1ef453092f1c028719 100644
--- a/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
+++ b/third_party/WebKit/Source/modules/webaudio/OfflineAudioContext.cpp
@@ -35,6 +35,7 @@
#include "modules/webaudio/OfflineAudioCompletionEvent.h"
#include "modules/webaudio/OfflineAudioDestinationNode.h"
+#include "platform/Histogram.h"
#include "platform/audio/AudioUtilities.h"
namespace blink {
@@ -90,6 +91,27 @@ OfflineAudioContext* OfflineAudioContext::create(ExecutionContext* context, unsi
+ ")");
}
+ DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextChannelCountHistogram,
+ ("WebAudio.OfflineAudioContext.ChannelCount"));
+ DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextLengthHistogram,
+ ("WebAudio.OfflineAudioContext.Length"));
+ DEFINE_STATIC_LOCAL(SparseHistogram, offlineContextSampleRateHistogram,
+ ("WebAudio.OfflineAudioContext.SampleRate"));
+
+ offlineContextChannelCountHistogram.sample(numberOfChannels);
+ // To limit the size of the histogram, record 10*log10(numberOfFrames),
+ // clipping the value at 60 (buffer size of 1 million frames). This
+ // gives 60 entries in the histogram.
+ double histogramValue = 10*log10(numberOfFrames);
+ offlineContextLengthHistogram.sample(clampTo(static_cast<int>(0.5 + histogramValue), 0, 60));
+
+ // To limit the size of the histogram, record
+ // 40+10*log2(sampleRate/48000), clipping the value to lie between 0
+ // and 60. These limits correspond to a min rate of 3000 and a max of
+ // 192000. This gives 60 entries in the histogram.
+ histogramValue = 40 + 10*log2(sampleRate / 48000);
+ offlineContextSampleRateHistogram.sample(clampTo(static_cast<int>(0.5 + histogramValue), 0, 60));
+
audioContext->suspendIfNeeded();
return audioContext;
}

Powered by Google App Engine
This is Rietveld 408576698