From 2c68ce930c32fa13470269c75357553f020bd44c Mon Sep 17 00:00:00 2001 From: lupoDharkael Date: Mon, 18 Feb 2019 01:25:26 +0100 Subject: Add CSV export to profiling data --- editor/editor_profiler.cpp | 57 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) (limited to 'editor/editor_profiler.cpp') diff --git a/editor/editor_profiler.cpp b/editor/editor_profiler.cpp index dee589ad3f..f73cd0beb5 100644 --- a/editor/editor_profiler.cpp +++ b/editor/editor_profiler.cpp @@ -625,6 +625,63 @@ bool EditorProfiler::is_profiling() { return activate->is_pressed(); } +Vector > EditorProfiler::get_data_as_csv() const { + Vector > res; + + if (frame_metrics.empty()) { + return res; + } + + // signatures + Vector signatures; + const Vector &categories = frame_metrics[0].categories; + + for (int j = 0; j < categories.size(); j++) { + + const EditorProfiler::Metric::Category &c = categories[j]; + signatures.push_back(c.signature); + + for (int k = 0; k < c.items.size(); k++) { + signatures.push_back(c.items[k].signature); + } + } + res.push_back(signatures); + + // values + Vector values; + values.resize(signatures.size()); + + int index = last_metric; + + for (int i = 0; i < frame_metrics.size(); i++) { + + ++index; + + if (index >= frame_metrics.size()) { + index = 0; + } + + if (!frame_metrics[index].valid) { + continue; + } + int it = 0; + const Vector &frame_cat = frame_metrics[index].categories; + + for (int j = 0; j < frame_cat.size(); j++) { + + const EditorProfiler::Metric::Category &c = frame_cat[j]; + values.write[it++] = String::num_real(c.total_time); + + for (int k = 0; k < c.items.size(); k++) { + values.write[it++] = String::num_real(c.items[k].total); + } + } + res.push_back(values); + } + + return res; +} + EditorProfiler::EditorProfiler() { HBoxContainer *hb = memnew(HBoxContainer); -- cgit v1.2.3