diff options
Diffstat (limited to 'indra/newview/llscenemonitor.cpp')
-rw-r--r-- | indra/newview/llscenemonitor.cpp | 218 |
1 files changed, 112 insertions, 106 deletions
diff --git a/indra/newview/llscenemonitor.cpp b/indra/newview/llscenemonitor.cpp index 2c0c38dc75..a16cb81255 100644 --- a/indra/newview/llscenemonitor.cpp +++ b/indra/newview/llscenemonitor.cpp @@ -531,157 +531,163 @@ void LLSceneMonitor::dumpToFile(std::string file_name) if (!hasResults()) return; LL_INFOS("SceneMonitor") << "Saving scene load stats to " << file_name << LL_ENDL; - - llofstream os(file_name.c_str()); - - os << std::setprecision(10); - - PeriodicRecording& scene_load_recording = mSceneLoadRecording.getResults(); - const U32 frame_count = scene_load_recording.getNumRecordedPeriods(); - - F64Seconds frame_time; - - os << "Stat"; - for (S32 frame = 1; frame <= frame_count; frame++) + try { - frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); - os << ", " << frame_time.value(); - } - os << '\n'; + llofstream os(file_name.c_str()); - os << "Sample period(s)"; - for (S32 frame = 1; frame <= frame_count; frame++) - { - frame_time = scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); - os << ", " << frame_time.value(); - } - os << '\n'; + os << std::setprecision(10); + PeriodicRecording& scene_load_recording = mSceneLoadRecording.getResults(); + const U32 frame_count = scene_load_recording.getNumRecordedPeriods(); - typedef StatType<CountAccumulator> trace_count; - for (auto& it : trace_count::instance_snapshot()) - { - std::ostringstream row; - row << std::setprecision(10); + F64Seconds frame_time; - row << it.getName(); - - const char* unit_label = it.getUnitLabel(); - if(unit_label[0]) + os << "Stat"; + for (S32 frame = 1; frame <= frame_count; frame++) { - row << "(" << unit_label << ")"; + frame_time += scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); + os << ", " << frame_time.value(); } + os << '\n'; - S32 samples = 0; - + os << "Sample period(s)"; for (S32 frame = 1; frame <= frame_count; frame++) { - Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); - samples += recording.getSampleCount(it); - row << ", " << recording.getSum(it); + frame_time = scene_load_recording.getPrevRecording(frame_count - frame).getDuration(); + os << ", " << frame_time.value(); } + os << '\n'; - row << '\n'; - if (samples > 0) + typedef StatType<CountAccumulator> trace_count; + for (auto& it : trace_count::instance_snapshot()) { - os << row.str(); - } - } - - typedef StatType<EventAccumulator> trace_event; + std::ostringstream row; + row << std::setprecision(10); - for (auto& it : trace_event::instance_snapshot()) - { - std::ostringstream row; - row << std::setprecision(10); - row << it.getName(); + row << it.getName(); - const char* unit_label = it.getUnitLabel(); - if(unit_label[0]) - { - row << "(" << unit_label << ")"; - } + const char* unit_label = it.getUnitLabel(); + if (unit_label[0]) + { + row << "(" << unit_label << ")"; + } - S32 samples = 0; + S32 samples = 0; - for (S32 frame = 1; frame <= frame_count; frame++) - { - Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); - samples += recording.getSampleCount(it); - F64 mean = recording.getMean(it); - if (llisnan(mean)) + for (S32 frame = 1; frame <= frame_count; frame++) { - row << ", n/a"; + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(it); + row << ", " << recording.getSum(it); } - else + + row << '\n'; + + if (samples > 0) { - row << ", " << mean; + os << row.str(); } } - row << '\n'; + typedef StatType<EventAccumulator> trace_event; - if (samples > 0) + for (auto& it : trace_event::instance_snapshot()) { - os << row.str(); - } - } + std::ostringstream row; + row << std::setprecision(10); + row << it.getName(); - typedef StatType<SampleAccumulator> trace_sample; + const char* unit_label = it.getUnitLabel(); + if (unit_label[0]) + { + row << "(" << unit_label << ")"; + } - for (auto& it : trace_sample::instance_snapshot()) - { - std::ostringstream row; - row << std::setprecision(10); - row << it.getName(); + S32 samples = 0; - const char* unit_label = it.getUnitLabel(); - if(unit_label[0]) - { - row << "(" << unit_label << ")"; + for (S32 frame = 1; frame <= frame_count; frame++) + { + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(it); + F64 mean = recording.getMean(it); + if (llisnan(mean)) + { + row << ", n/a"; + } + else + { + row << ", " << mean; + } + } + + row << '\n'; + + if (samples > 0) + { + os << row.str(); + } } - S32 samples = 0; + typedef StatType<SampleAccumulator> trace_sample; - for (S32 frame = 1; frame <= frame_count; frame++) + for (auto& it : trace_sample::instance_snapshot()) { - Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); - samples += recording.getSampleCount(it); - F64 mean = recording.getMean(it); - if (llisnan(mean)) + std::ostringstream row; + row << std::setprecision(10); + row << it.getName(); + + const char* unit_label = it.getUnitLabel(); + if (unit_label[0]) + { + row << "(" << unit_label << ")"; + } + + S32 samples = 0; + + for (S32 frame = 1; frame <= frame_count; frame++) { - row << ", n/a"; + Recording& recording = scene_load_recording.getPrevRecording(frame_count - frame); + samples += recording.getSampleCount(it); + F64 mean = recording.getMean(it); + if (llisnan(mean)) + { + row << ", n/a"; + } + else + { + row << ", " << mean; + } } - else + + row << '\n'; + + if (samples > 0) { - row << ", " << mean; + os << row.str(); } } - row << '\n'; - - if (samples > 0) + typedef StatType<MemAccumulator> trace_mem; + for (auto& it : trace_mem::instance_snapshot()) { - os << row.str(); - } - } + os << it.getName() << "(KiB)"; - typedef StatType<MemAccumulator> trace_mem; - for (auto& it : trace_mem::instance_snapshot()) - { - os << it.getName() << "(KiB)"; + for (S32 frame = 1; frame <= frame_count; frame++) + { + os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(it).valueInUnits<LLUnits::Kilobytes>(); + } - for (S32 frame = 1; frame <= frame_count; frame++) - { - os << ", " << scene_load_recording.getPrevRecording(frame_count - frame).getMax(it).valueInUnits<LLUnits::Kilobytes>(); + os << '\n'; } - os << '\n'; + os.flush(); + os.close(); + } + catch (const std::ios_base::failure &e) + { + LL_WARNS() << "Unable to dump scene monitor results: " << e.what() << LL_ENDL; } - - os.flush(); - os.close(); } //------------------------------------------------------------------------------------------------------------- |