Commit 237ff18a authored by Hajime Hoshi's avatar Hajime Hoshi Committed by Commit Bot

Remove Timer usages from TimerPerfTest

This is part of efforts to replace default timer task runners with
other appropriate task runners in the renderer.

Bug: 624694, 804694
Change-Id: I72ba24174da8d1557d4963b0f4336b50b2f01667
Reviewed-on: https://chromium-review.googlesource.com/925124Reviewed-by: default avatarAlexander Timin <altimin@chromium.org>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Hajime Hoshi <hajimehoshi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#537613}
parent ab507687
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "platform/wtf/PtrUtil.h" #include "platform/wtf/PtrUtil.h"
#include "platform/wtf/Vector.h" #include "platform/wtf/Vector.h"
#include "public/platform/Platform.h" #include "public/platform/Platform.h"
#include "public/platform/scheduler/test/renderer_scheduler_test_support.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace blink { namespace blink {
...@@ -32,14 +33,20 @@ class TimerPerfTest : public ::testing::Test { ...@@ -32,14 +33,20 @@ class TimerPerfTest : public ::testing::Test {
TEST_F(TimerPerfTest, PostAndRunTimers) { TEST_F(TimerPerfTest, PostAndRunTimers) {
const int kNumIterations = 10000; const int kNumIterations = 10000;
Vector<std::unique_ptr<Timer<TimerPerfTest>>> timers(kNumIterations); Vector<std::unique_ptr<TaskRunnerTimer<TimerPerfTest>>> timers(
kNumIterations);
for (int i = 0; i < kNumIterations; i++) { for (int i = 0; i < kNumIterations; i++) {
timers[i].reset(new Timer<TimerPerfTest>(this, &TimerPerfTest::NopTask)); timers[i].reset(new TaskRunnerTimer<TimerPerfTest>(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::NopTask));
} }
Timer<TimerPerfTest> measure_run_start(this, TaskRunnerTimer<TimerPerfTest> measure_run_start(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::RecordStartRunTime); &TimerPerfTest::RecordStartRunTime);
Timer<TimerPerfTest> measure_run_end(this, &TimerPerfTest::RecordEndRunTime); TaskRunnerTimer<TimerPerfTest> measure_run_end(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::RecordEndRunTime);
measure_run_start.StartOneShot(TimeDelta(), FROM_HERE); measure_run_start.StartOneShot(TimeDelta(), FROM_HERE);
base::ThreadTicks post_start = base::ThreadTicks::Now(); base::ThreadTicks post_start = base::ThreadTicks::Now();
...@@ -62,14 +69,20 @@ TEST_F(TimerPerfTest, PostAndRunTimers) { ...@@ -62,14 +69,20 @@ TEST_F(TimerPerfTest, PostAndRunTimers) {
TEST_F(TimerPerfTest, PostThenCancelTenThousandTimers) { TEST_F(TimerPerfTest, PostThenCancelTenThousandTimers) {
const int kNumIterations = 10000; const int kNumIterations = 10000;
Vector<std::unique_ptr<Timer<TimerPerfTest>>> timers(kNumIterations); Vector<std::unique_ptr<TaskRunnerTimer<TimerPerfTest>>> timers(
kNumIterations);
for (int i = 0; i < kNumIterations; i++) { for (int i = 0; i < kNumIterations; i++) {
timers[i].reset(new Timer<TimerPerfTest>(this, &TimerPerfTest::NopTask)); timers[i].reset(new TaskRunnerTimer<TimerPerfTest>(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::NopTask));
} }
Timer<TimerPerfTest> measure_run_start(this, TaskRunnerTimer<TimerPerfTest> measure_run_start(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::RecordStartRunTime); &TimerPerfTest::RecordStartRunTime);
Timer<TimerPerfTest> measure_run_end(this, &TimerPerfTest::RecordEndRunTime); TaskRunnerTimer<TimerPerfTest> measure_run_end(
scheduler::GetSingleThreadTaskRunnerForTesting(), this,
&TimerPerfTest::RecordEndRunTime);
measure_run_start.StartOneShot(TimeDelta(), FROM_HERE); measure_run_start.StartOneShot(TimeDelta(), FROM_HERE);
base::ThreadTicks post_start = base::ThreadTicks::Now(); base::ThreadTicks post_start = base::ThreadTicks::Now();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment