-
Notifications
You must be signed in to change notification settings - Fork 121
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added the ability to track the latency of `WebMediaPlayer` actions to the existing `MediaMetricsProvider` class, and instrumented `Seek` as the first action. Added basic unit tests for the new code. b/329439521 Change-Id: Icbbfd0da148e48d2137da7662b91e6e2d52de590 (cherry picked from commit a712047)
- Loading branch information
1 parent
7bffd2e
commit 609208a
Showing
6 changed files
with
173 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// Copyright 2024 The Cobalt Authors. All Rights Reserved. | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://www.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
#include "cobalt/media/base/metrics_provider.h" | ||
|
||
#include <memory> | ||
#include <string> | ||
|
||
#include "base/test/metrics/histogram_tester.h" | ||
#include "base/test/simple_test_tick_clock.h" | ||
#include "base/time/time.h" | ||
#include "testing/gtest/include/gtest/gtest.h" | ||
|
||
namespace cobalt { | ||
namespace media { | ||
namespace { | ||
constexpr char kUmaPrefix[] = "Cobalt.Media."; | ||
|
||
class MediaMetricsProviderTest : public ::testing::Test { | ||
protected: | ||
MediaMetricsProviderTest() : metrics_(&clock_) {} | ||
|
||
void SetUp() override { clock_.SetNowTicks(base::TimeTicks()); } | ||
|
||
base::HistogramTester histogram_tester_; | ||
base::SimpleTestTickClock clock_; | ||
|
||
MediaMetricsProvider metrics_; | ||
}; | ||
|
||
TEST_F(MediaMetricsProviderTest, ReportsSeekLatency) { | ||
metrics_.Initialize(true); | ||
metrics_.StartTrackingAction(WebMediaPlayerAction::SEEK); | ||
|
||
clock_.Advance(base::TimeDelta::FromMilliseconds(100)); | ||
metrics_.EndTrackingAction(WebMediaPlayerAction::SEEK); | ||
|
||
histogram_tester_.ExpectUniqueSample( | ||
std::string(kUmaPrefix) + "WebMediaPlayer.Seek.Timing", 100, 1); | ||
} | ||
|
||
TEST_F(MediaMetricsProviderTest, SupportsTrackingMultipleActions) { | ||
metrics_.Initialize(true); | ||
metrics_.StartTrackingAction(WebMediaPlayerAction::SEEK); | ||
metrics_.StartTrackingAction(WebMediaPlayerAction::UNKNOWN_ACTION); | ||
|
||
clock_.Advance(base::TimeDelta::FromMilliseconds(100)); | ||
metrics_.EndTrackingAction(WebMediaPlayerAction::UNKNOWN_ACTION); | ||
|
||
clock_.Advance(base::TimeDelta::FromMilliseconds(1000)); | ||
metrics_.EndTrackingAction(WebMediaPlayerAction::SEEK); | ||
|
||
histogram_tester_.ExpectUniqueSample( | ||
std::string(kUmaPrefix) + "WebMediaPlayer.Seek.Timing", 1100, 1); | ||
} | ||
|
||
} // namespace | ||
} // namespace media | ||
} // namespace cobalt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,6 +185,17 @@ Always run the pretty print utility on this file after editing: | |
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.Media.WebMediaPlayer.Seek.Timing" | ||
units="milliseconds" expires_after="never"> | ||
<!-- expires-never: Needed for long-term tracking of Seek latency. --> | ||
|
||
<owner>[email protected]</owner> | ||
<owner>[email protected]</owner> | ||
<summary> | ||
Timing data for the seek latency of WebMediaPlayer. | ||
</summary> | ||
</histogram> | ||
|
||
<histogram name="Cobalt.MediaDevices.MicCreationSucceeded" enum="Boolean" | ||
expires_after="never"> | ||
<!-- expires-never: Needed for long-term tracking of device mic support. --> | ||
|