| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "ui/events/latency_info.h" | 5 #include "ui/events/latency_info.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 TRACE_EVENT_WITH_FLOW1("input,benchmark", | 272 TRACE_EVENT_WITH_FLOW1("input,benchmark", |
| 273 "LatencyInfo.Flow", | 273 "LatencyInfo.Flow", |
| 274 TRACE_ID_DONT_MANGLE(trace_id_), | 274 TRACE_ID_DONT_MANGLE(trace_id_), |
| 275 TRACE_EVENT_FLAG_FLOW_OUT, | 275 TRACE_EVENT_FLAG_FLOW_OUT, |
| 276 "trace_id", trace_id_); | 276 "trace_id", trace_id_); |
| 277 } | 277 } |
| 278 | 278 |
| 279 LatencyMap::key_type key = std::make_pair(component, id); | 279 LatencyMap::key_type key = std::make_pair(component, id); |
| 280 LatencyMap::iterator it = latency_components_.find(key); | 280 LatencyMap::iterator it = latency_components_.find(key); |
| 281 if (it == latency_components_.end()) { | 281 if (it == latency_components_.end()) { |
| 282 LatencyComponent info = {component_sequence_number, time, event_count}; | 282 LatencyComponent info = {component_sequence_number, time, event_count, time, |
| 283 time}; |
| 283 latency_components_[key] = info; | 284 latency_components_[key] = info; |
| 284 } else { | 285 } else { |
| 285 it->second.sequence_number = std::max(component_sequence_number, | 286 it->second.sequence_number = std::max(component_sequence_number, |
| 286 it->second.sequence_number); | 287 it->second.sequence_number); |
| 287 uint32_t new_count = event_count + it->second.event_count; | 288 uint32_t new_count = event_count + it->second.event_count; |
| 288 if (event_count > 0 && new_count != 0) { | 289 if (event_count > 0 && new_count != 0) { |
| 289 // Do a weighted average, so that the new event_time is the average of | 290 // Do a weighted average, so that the new event_time is the average of |
| 290 // the times of events currently in this structure with the time passed | 291 // the times of events currently in this structure with the time passed |
| 291 // into this method. | 292 // into this method. |
| 292 it->second.event_time += (time - it->second.event_time) * event_count / | 293 it->second.event_time += (time - it->second.event_time) * event_count / |
| 293 new_count; | 294 new_count; |
| 294 it->second.event_count = new_count; | 295 it->second.event_count = new_count; |
| 296 it->second.last_event_time = std::max(it->second.last_event_time, time); |
| 295 } | 297 } |
| 296 } | 298 } |
| 297 | 299 |
| 298 if (IsTerminalComponent(component) && trace_id_ != -1) { | 300 if (IsTerminalComponent(component) && trace_id_ != -1) { |
| 299 // Should only ever add terminal component once. | 301 // Should only ever add terminal component once. |
| 300 CHECK(!terminated_); | 302 CHECK(!terminated_); |
| 301 terminated_ = true; | 303 terminated_ = true; |
| 302 | 304 |
| 303 if (*latency_info_enabled) { | 305 if (*latency_info_enabled) { |
| 304 TRACE_EVENT_COPY_ASYNC_END2(kTraceCategoriesForAsyncEvents, | 306 TRACE_EVENT_COPY_ASYNC_END2(kTraceCategoriesForAsyncEvents, |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 372 } | 374 } |
| 373 | 375 |
| 374 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { | 376 bool LatencyInfo::AddInputCoordinate(const gfx::PointF& input_coordinate) { |
| 375 if (input_coordinates_size_ >= kMaxInputCoordinates) | 377 if (input_coordinates_size_ >= kMaxInputCoordinates) |
| 376 return false; | 378 return false; |
| 377 input_coordinates_[input_coordinates_size_++] = input_coordinate; | 379 input_coordinates_[input_coordinates_size_++] = input_coordinate; |
| 378 return true; | 380 return true; |
| 379 } | 381 } |
| 380 | 382 |
| 381 } // namespace ui | 383 } // namespace ui |
| OLD | NEW |