summaryrefslogtreecommitdiff
path: root/editor/editor_profiler.cpp
diff options
context:
space:
mode:
authorRĂ©mi Verschelde <rverschelde@gmail.com>2019-04-06 13:12:20 +0200
committerGitHub <noreply@github.com>2019-04-06 13:12:20 +0200
commit0b747f5312504d51097382fd6e39fd9a743a6086 (patch)
treec2caf77d206ee34d924d13d76844af1c17fe11ed /editor/editor_profiler.cpp
parentb319168db289cecc0c11af57371ddbbb0766ab85 (diff)
parent2c68ce930c32fa13470269c75357553f020bd44c (diff)
Merge pull request #25995 from lupoDharkael/csv
Add CSV export to profiling data
Diffstat (limited to 'editor/editor_profiler.cpp')
-rw-r--r--editor/editor_profiler.cpp57
1 files changed, 57 insertions, 0 deletions
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<Vector<String> > EditorProfiler::get_data_as_csv() const {
+ Vector<Vector<String> > res;
+
+ if (frame_metrics.empty()) {
+ return res;
+ }
+
+ // signatures
+ Vector<String> signatures;
+ const Vector<EditorProfiler::Metric::Category> &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<String> 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<EditorProfiler::Metric::Category> &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);