Chromium Code Reviews| Index: cc/debug/performance_draw_timing_counter.cc |
| diff --git a/cc/debug/performance_draw_timing_counter.cc b/cc/debug/performance_draw_timing_counter.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..08a1302ecb352a0f1a6ca355c348123f75cf9138 |
| --- /dev/null |
| +++ b/cc/debug/performance_draw_timing_counter.cc |
| @@ -0,0 +1,58 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "cc/debug/performance_draw_timing_counter.h" |
| + |
| +#include <algorithm> |
| +#include <limits> |
| + |
| +#include "base/metrics/histogram.h" |
| +#include "cc/trees/proxy.h" |
| + |
| +namespace cc { |
| + |
| +// static |
| +scoped_ptr<PerformanceDrawTimingCounter> |
| +PerformanceDrawTimingCounter::Create() { |
| + return make_scoped_ptr(new PerformanceDrawTimingCounter); |
| +} |
| + |
| +PerformanceDrawTimingCounter::PerformanceDrawTimingCounter() { |
| +} |
| + |
| +void PerformanceDrawTimingCounter::SaveTimeStamp(int frame_id, int64_t rect_id, |
| + base::TimeTicks timestamp) { |
| + struct DrawEvent drawEvent(frame_id, rect_id, timestamp); |
| + ring_buffer_.SaveToBuffer(drawEvent); |
| +} |
| + |
| +void PerformanceDrawTimingCounter::SaveTimeStamps(base::TimeTicks timestamp, |
| + const std::vector<std::pair<int, int64_t> > &frame_ids) { |
| + for (std::vector<std::pair<int, int64_t> >::const_iterator it = |
| + frame_ids.begin(); it != frame_ids.end(); ++it) { |
| + struct DrawEvent drawEvent(it->first, it->second, timestamp); |
|
enne (OOO)
2014/07/22 20:44:24
style nit: draw_event, no struct
bikeshed: Maybe
Mike B
2014/07/25 23:09:40
Done.
|
| + ring_buffer_.SaveToBuffer(drawEvent); |
| + } |
| +} |
| + |
| +scoped_ptr<DrawTimingSet> PerformanceDrawTimingCounter::getDrawTimingCounts() { |
| + typedef base::hash_map |
| + <int64_t, std::vector<std::pair<int, base::TimeTicks> > > DrawsByRectId; |
| + DrawsByRectId id_map; |
| + for (RingBufferType::Iterator it = begin(); it; ++it) { |
| + id_map[it->rect_id_].push_back(std::make_pair(it->frame_id_, |
| + it->timestamp_)); |
| + } |
| + scoped_ptr<DrawTimingSet> draws_info(new DrawTimingSet); |
| + for (DrawsByRectId::iterator id = id_map.begin(); id != id_map.end(); ++id) { |
| + LayerTreeHostCommon::DrawTimingInfo draw; |
| + draw.rect_id = id->first; |
| + draw.timestamps = id->second; |
| + std::sort(draw.timestamps.begin(), draw.timestamps.end()); |
| + draws_info->draws.push_back(draw); |
| + } |
| + return draws_info.Pass(); |
| +} |
| + |
| +} // namespace cc |