| Index: content/renderer/render_widget.cc
|
| diff --git a/content/renderer/render_widget.cc b/content/renderer/render_widget.cc
|
| index 44b971f2036e0f36859ef9bed72062ea6597cab5..069f41af8861dea654c35c787682bec68ca5570f 100644
|
| --- a/content/renderer/render_widget.cc
|
| +++ b/content/renderer/render_widget.cc
|
| @@ -4,6 +4,9 @@
|
|
|
| #include "content/renderer/render_widget.h"
|
|
|
| +#include <fstream>
|
| +#include <iostream>
|
| +
|
| #include "base/auto_reset.h"
|
| #include "base/bind.h"
|
| #include "base/command_line.h"
|
| @@ -91,8 +94,14 @@
|
| #include "third_party/skia/include/core/SkPixelRef.h"
|
| #endif // defined(OS_POSIX)
|
|
|
| +#include "base/threading/platform_thread.h"
|
| +#include "content/renderer/greenweb_latency_tracking.h"
|
| #include "third_party/WebKit/public/web/WebWidget.h"
|
|
|
| +std::map<int64, GreenWebLatencyComponent> InputLatencyMap;
|
| +std::map<int64, DOMLatencyMapComponent> DOMLatencyMap;
|
| +int64 InputLatencyID;
|
| +
|
| using blink::WebCompositionUnderline;
|
| using blink::WebCursorInfo;
|
| using blink::WebDeviceEmulationParams;
|
| @@ -1067,10 +1076,43 @@ void RenderWidget::OnSwapBuffersComplete() {
|
| DidFlushPaint();
|
| }
|
|
|
| +void read_freq_stat(std::map<int64, int64> *stat)
|
| +{
|
| + std::ifstream freqstat("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
|
| +
|
| + int freq, time;
|
| + while (freqstat >> freq >> time)
|
| + {
|
| + (*stat)[freq] = time;
|
| + }
|
| +
|
| + freqstat.close();
|
| +}
|
| +
|
| +void process_freq_stat(std::map<int64, int64> *startMap, std::map<int64, int64> *statMap)
|
| +{
|
| + std::ifstream freqstat("/sys/devices/system/cpu/cpu0/cpufreq/stats/time_in_state");
|
| +
|
| + int freq, time;
|
| + while (freqstat >> freq >> time)
|
| + {
|
| + (*statMap)[freq] = time - (*startMap)[freq];
|
| + }
|
| +
|
| + freqstat.close();
|
| +}
|
| +
|
| void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
|
| const ui::LatencyInfo& latency_info) {
|
| if (!input_event)
|
| return;
|
| +
|
| + base::TimeTicks callback_start_ts = base::TimeTicks::Now();
|
| + int64 trace_id = latency_info.trace_id();
|
| + InputLatencyID = trace_id;
|
| +
|
| + read_freq_stat(&(InputLatencyMap[trace_id].FreqStatStartMap));
|
| +
|
| base::AutoReset<bool> handling_input_event_resetter(&handling_input_event_,
|
| true);
|
| base::AutoReset<WebInputEvent::Type> handling_event_type_resetter(
|
| @@ -1107,7 +1149,8 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
|
|
|
| base::TimeTicks start_time;
|
| if (base::TimeTicks::IsHighResolution())
|
| - start_time = base::TimeTicks::Now();
|
| + start_time = callback_start_ts;
|
| + //start_time = base::TimeTicks::Now();
|
|
|
| TRACE_EVENT1("renderer,benchmark", "RenderWidget::OnHandleInputEvent",
|
| "event", WebInputEventTraits::GetName(input_event->type));
|
| @@ -1222,8 +1265,9 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
|
| bool rate_limiting_wanted =
|
| input_event->type == WebInputEvent::MouseMove ||
|
| input_event->type == WebInputEvent::MouseWheel;
|
| + base::TimeTicks end_time;
|
| if (rate_limiting_wanted && !start_time.is_null()) {
|
| - base::TimeTicks end_time = base::TimeTicks::Now();
|
| + end_time = base::TimeTicks::Now();
|
| total_input_handling_time_this_frame_ += (end_time - start_time);
|
| rate_limiting_wanted =
|
| total_input_handling_time_this_frame_.InMicroseconds() >
|
| @@ -1304,6 +1348,30 @@ void RenderWidget::OnHandleInputEvent(const blink::WebInputEvent* input_event,
|
| FocusChangeComplete();
|
| }
|
| #endif
|
| +
|
| + int64 dom_node = InputLatencyMap[trace_id].dom_node;
|
| + if (dom_node) {
|
| + base::TimeTicks callback_end_ts = base::TimeTicks::Now();
|
| + base::TimeDelta callback_latency = callback_end_ts - callback_start_ts;
|
| + int64 callback_latency_in_ms = callback_latency.InMilliseconds();
|
| +
|
| + InputLatencyMap[trace_id].callback_start = callback_start_ts;
|
| + InputLatencyMap[trace_id].latency = callback_latency_in_ms;
|
| +
|
| + DOMLatencyMap[dom_node].latency = InputLatencyMap[trace_id].latency;
|
| +
|
| + process_freq_stat(&(InputLatencyMap[trace_id].FreqStatStartMap), &(DOMLatencyMap[dom_node].FreqStatMap));
|
| +
|
| +#ifdef EBS_DEBUG_TRACE_EVENT
|
| + TRACE_EVENT2("devtools.timeline", "GreenWeb:Callback", "trace_id", trace_id, "latency", DOMLatencyMap[dom_node].latency);
|
| + std::cout << "Thd: " << base::PlatformThread::CurrentId() <<
|
| + " (" << base::PlatformThread::GetName() << ")" <<
|
| + " Callback "
|
| + " trace_id " << trace_id <<
|
| + " dom_node " << dom_node <<
|
| + " latency " << DOMLatencyMap[dom_node].latency << std::endl;
|
| +#endif
|
| + }
|
| }
|
|
|
| void RenderWidget::OnCursorVisibilityChange(bool is_visible) {
|
|
|