Commit ff8c0a23 authored by Majid Valipour's avatar Majid Valipour Committed by Commit Bot

Allow base::ElapsedTimer use in Blink

ElapsedTimer is a small useful utility class for measuring time.
As a wise Greek may put it: "The unmeasured time is not worth having".

Here is discussion that inspired this CL: https://chromium-review.googlesource.com/c/chromium/src/+/951922#message-fca340ea66b052ad7ee1d6e92d42b61ac549456d

Change-Id: Iebd3d49c1965fd0b1a16ad0eeee7af302a6afbf3
Reviewed-on: https://chromium-review.googlesource.com/c/1295177Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Commit-Queue: Majid Valipour <majidvp@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601896}
parent 6240d9ae
...@@ -31,6 +31,7 @@ include_rules = [ ...@@ -31,6 +31,7 @@ include_rules = [
"+base/thread_annotations.h", "+base/thread_annotations.h",
"+base/threading/thread_checker.h", "+base/threading/thread_checker.h",
"+base/time/time.h", "+base/time/time.h",
"+base/timer/elapsed_timer.h",
"+build", "+build",
"+services/service_manager/public/cpp/connector.h", "+services/service_manager/public/cpp/connector.h",
"+services/service_manager/public/cpp/interface_provider.h", "+services/service_manager/public/cpp/interface_provider.h",
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope.h" #include "third_party/blink/renderer/modules/animationworklet/animation_worklet_global_scope.h"
#include "base/metrics/histogram_macros.h" #include "base/metrics/histogram_macros.h"
#include "base/timer/elapsed_timer.h"
#include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h" #include "third_party/blink/renderer/bindings/core/v8/serialization/serialized_script_value.h"
#include "third_party/blink/renderer/bindings/core/v8/v8_object_parser.h" #include "third_party/blink/renderer/bindings/core/v8/v8_object_parser.h"
#include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h" #include "third_party/blink/renderer/bindings/core/v8/worker_or_worklet_script_controller.h"
...@@ -80,7 +81,7 @@ Animator* AnimationWorkletGlobalScope::CreateAnimatorFor( ...@@ -80,7 +81,7 @@ Animator* AnimationWorkletGlobalScope::CreateAnimatorFor(
std::unique_ptr<AnimationWorkletOutput> AnimationWorkletGlobalScope::Mutate( std::unique_ptr<AnimationWorkletOutput> AnimationWorkletGlobalScope::Mutate(
const AnimationWorkletInput& mutator_input) { const AnimationWorkletInput& mutator_input) {
base::TimeTicks start_time = CurrentTimeTicks(); base::ElapsedTimer timer;
DCHECK(IsContextThread()); DCHECK(IsContextThread());
ScriptState* script_state = ScriptController()->GetScriptState(); ScriptState* script_state = ScriptController()->GetScriptState();
...@@ -135,8 +136,8 @@ std::unique_ptr<AnimationWorkletOutput> AnimationWorkletGlobalScope::Mutate( ...@@ -135,8 +136,8 @@ std::unique_ptr<AnimationWorkletOutput> AnimationWorkletGlobalScope::Mutate(
} }
UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES( UMA_HISTOGRAM_CUSTOM_MICROSECONDS_TIMES(
"Animation.AnimationWorklet.GlobalScope.MutateDuration", "Animation.AnimationWorklet.GlobalScope.MutateDuration", timer.Elapsed(),
CurrentTimeTicks() - start_time, base::TimeDelta::FromMicroseconds(1), base::TimeDelta::FromMicroseconds(1),
base::TimeDelta::FromMilliseconds(100), 50); base::TimeDelta::FromMilliseconds(100), 50);
return result; return result;
......
...@@ -32,6 +32,7 @@ _CONFIG = [ ...@@ -32,6 +32,7 @@ _CONFIG = [
# //base constructs that are allowed everywhere # //base constructs that are allowed everywhere
'base::AdoptRef', 'base::AdoptRef',
'base::AutoReset', 'base::AutoReset',
'base::ElapsedTimer',
'base::File', 'base::File',
'base::FilePath', 'base::FilePath',
'base::GetUniqueIdForProcess', 'base::GetUniqueIdForProcess',
......
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