Commit fc2f00d3 authored by Camillo Bruni's avatar Camillo Bruni Committed by Commit Bot

[counters] CPU time for RCS

The newly introduced --rcs-cpu-time flag enables CPU time for all
runtime call stats timers. By default we still keep on using good
old wall time.

This CL also adds the long-awaited --rcs short flag.

Change-Id: I3173e3a0f846ec3bf0d319624a37741c56914be5
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2060304Reviewed-by: 's avatarRoss McIlroy <rmcilroy@chromium.org>
Commit-Queue: Camillo Bruni <cbruni@chromium.org>
Cr-Commit-Position: refs/heads/master@{#66427}
parent 443721bd
......@@ -1289,6 +1289,12 @@ DEFINE_GENERIC_IMPLICATION(
runtime_call_stats,
TracingFlags::runtime_stats.store(
v8::tracing::TracingCategoryObserver::ENABLED_BY_NATIVE))
DEFINE_BOOL(rcs, false, "report runtime call counts and times")
DEFINE_IMPLICATION(rcs, runtime_call_stats)
DEFINE_BOOL(rcs_cpu_time, false,
"report runtime times in cpu time (the default is wall time)")
DEFINE_IMPLICATION(rcs_cpu_time, rcs)
// snapshot-common.cc
DEFINE_BOOL(profile_deserialization, false,
......
......@@ -319,6 +319,11 @@ void Counters::ResetCreateHistogramFunction(CreateHistogramCallback f) {
base::TimeTicks (*RuntimeCallTimer::Now)() =
&base::TimeTicks::HighResolutionNow;
base::TimeTicks RuntimeCallTimer::NowCPUTime() {
base::ThreadTicks ticks = base::ThreadTicks::Now();
return base::TimeTicks::FromInternalValue(ticks.ToInternalValue());
}
class RuntimeCallStatEntries {
public:
void Print(std::ostream& os) {
......@@ -454,6 +459,11 @@ RuntimeCallStats::RuntimeCallStats(ThreadType thread_type)
for (int i = 0; i < kNumberOfCounters; i++) {
this->counters_[i] = RuntimeCallCounter(kNames[i]);
}
if (FLAG_rcs_cpu_time) {
CHECK(base::ThreadTicks::IsSupported());
base::ThreadTicks::WaitUntilInitialized();
RuntimeCallTimer::Now = &RuntimeCallTimer::NowCPUTime;
}
}
namespace {
......
......@@ -714,6 +714,9 @@ class RuntimeCallTimer final {
// Make the time source configurable for testing purposes.
V8_EXPORT_PRIVATE static base::TimeTicks (*Now)();
// Helper to switch over to CPU time.
static base::TimeTicks NowCPUTime();
private:
inline void Pause(base::TimeTicks now);
inline void Resume(base::TimeTicks 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