| 178 | } |
| 179 | |
| 180 | void ScriptEditorDebugger::_file_selected(const String &p_file) { |
| 181 | switch (file_dialog_purpose) { |
| 182 | case SAVE_MONITORS_CSV: { |
| 183 | Error err; |
| 184 | Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); |
| 185 | |
| 186 | if (err != OK) { |
| 187 | ERR_PRINT("Failed to open " + p_file); |
| 188 | return; |
| 189 | } |
| 190 | Vector<String> line; |
| 191 | line.resize(Performance::MONITOR_MAX); |
| 192 | |
| 193 | // signatures |
| 194 | for (int i = 0; i < Performance::MONITOR_MAX; i++) { |
| 195 | line.write[i] = Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)); |
| 196 | } |
| 197 | file->store_csv_line(line); |
| 198 | |
| 199 | // values |
| 200 | Vector<List<float>::Element *> iterators; |
| 201 | iterators.resize(Performance::MONITOR_MAX); |
| 202 | bool continue_iteration = false; |
| 203 | for (int i = 0; i < Performance::MONITOR_MAX; i++) { |
| 204 | iterators.write[i] = performance_profiler->get_monitor_data(Performance::get_singleton()->get_monitor_name(Performance::Monitor(i)))->back(); |
| 205 | continue_iteration = continue_iteration || iterators[i]; |
| 206 | } |
| 207 | while (continue_iteration) { |
| 208 | continue_iteration = false; |
| 209 | for (int i = 0; i < Performance::MONITOR_MAX; i++) { |
| 210 | if (iterators[i]) { |
| 211 | line.write[i] = String::num_real(iterators[i]->get()); |
| 212 | iterators.write[i] = iterators[i]->prev(); |
| 213 | } else { |
| 214 | line.write[i] = ""; |
| 215 | } |
| 216 | continue_iteration = continue_iteration || iterators[i]; |
| 217 | } |
| 218 | file->store_csv_line(line); |
| 219 | } |
| 220 | file->store_string("\n"); |
| 221 | |
| 222 | Vector<Vector<String>> profiler_data = profiler->get_data_as_csv(); |
| 223 | for (int i = 0; i < profiler_data.size(); i++) { |
| 224 | file->store_csv_line(profiler_data[i]); |
| 225 | } |
| 226 | } break; |
| 227 | case SAVE_VRAM_CSV: { |
| 228 | Error err; |
| 229 | Ref<FileAccess> file = FileAccess::open(p_file, FileAccess::WRITE, &err); |
| 230 | |
| 231 | if (err != OK) { |
| 232 | ERR_PRINT("Failed to open " + p_file); |
| 233 | return; |
| 234 | } |
| 235 | |
| 236 | Vector<String> headers; |
| 237 | headers.resize(vmem_tree->get_columns()); |
nothing calls this directly
no test coverage detected