| 181 | void Stats::ReportOnDestruction() { report_on_destruction = true; } |
| 182 | |
| 183 | std::string Stats::CreateReport() { |
| 184 | std::ostringstream ss; |
| 185 | ss << std::left; |
| 186 | |
| 187 | auto print_common_stats = [&ss](const char* field_name, const ValueMax32& stat) { |
| 188 | ss << std::setw(32) << field_name; |
| 189 | ss << std::setw(12) << stat.value.u32 << stat.max_value.u32; |
| 190 | ss << "\n"; |
| 191 | }; |
| 192 | auto print_common_stats64 = [&ss](const char* field_name, uint64_t v1, uint64_t v2) { |
| 193 | ss << std::setw(32) << field_name; |
| 194 | ss << std::setw(12) << v1 << v2; |
| 195 | ss << "\n"; |
| 196 | }; |
| 197 | auto print_access_state_stats = [&ss](const char* context_type, const AccessContextStats& stats) { |
| 198 | ss << std::setw(13) << std::string(context_type) + "(" + std::to_string(stats.access_contexts) + ")"; |
| 199 | ss << std::setw(11) << stats.access_states; |
| 200 | |
| 201 | const uint64_t access_state_objects_size = sizeof(AccessState) * stats.access_states; |
| 202 | const double size_mb = ((double)access_state_objects_size / 1024.0 / 1024.0); |
| 203 | ss << std::fixed << std::setprecision(2) << std::setw(11) << size_mb; |
| 204 | ss.unsetf(std::ios::floatfield); |
| 205 | |
| 206 | ss << std::setw(2) << "| "; |
| 207 | ss << std::setw(10) << stats.read_states; |
| 208 | ss << std::setw(10) << stats.write_states; |
| 209 | ss << std::setw(9) << stats.first_accesses; |
| 210 | |
| 211 | ss << std::setw(2) << "| "; |
| 212 | ss << std::setw(12) << stats.access_states_with_multiple_reads; |
| 213 | ss << std::setw(13) << stats.access_states_with_multiple_firsts; |
| 214 | ss << std::setw(13) << stats.access_states_with_dynamic_allocations; |
| 215 | ss << std::setw(15) << stats.access_states_dynamic_allocation_size; |
| 216 | ss << "\n"; |
| 217 | }; |
| 218 | |
| 219 | ss << "-----------------------\n"; |
| 220 | ss << "Common stats count max_count\n"; |
| 221 | ss << "-----------------------\n"; |
| 222 | print_common_stats("CommandBufferAccessContext", command_buffer_contexts); |
| 223 | print_common_stats("QueueBatchContext", queue_batch_contexts); |
| 224 | print_common_stats("Timeline signal", timeline_signals); |
| 225 | print_common_stats("Unresolved batch", unresolved_batches); |
| 226 | print_common_stats("HandleRecord", handle_records); |
| 227 | |
| 228 | uint64_t handle_record_memory = handle_records.value.u32 * sizeof(HandleRecord); |
| 229 | uint64_t handle_record_max_memory = handle_records.max_value.u32 * sizeof(HandleRecord); |
| 230 | print_common_stats64("HandleRecord bytes", handle_record_memory, handle_record_max_memory); |
| 231 | |
| 232 | const char* access_stats_header = |
| 233 | "context accesses size (MB) | reads writes firsts | many_reads many_firsts have_allocs allocated (B)\n"; |
| 234 | |
| 235 | ss << "\n"; |
| 236 | ss << "-----------------------\n"; |
| 237 | ss << "AccessState stats\n"; |
| 238 | ss << "-----------------------\n"; |
| 239 | ss << access_stats_header; |
| 240 | print_access_state_stats("CB", access_stats.cb_access_stats); |
no test coverage detected