| 804 | }; |
| 805 | |
| 806 | class ctrack_result |
| 807 | { |
| 808 | public: |
| 809 | ctrack_result(const ctrack_result_settings &settings, const std::chrono::high_resolution_clock::time_point &track_start_time, const std::chrono::high_resolution_clock::time_point &track_end_time) : settings(settings), track_start_time(track_start_time), track_end_time(track_end_time) |
| 810 | { |
| 811 | time_total = std::chrono::duration_cast<std::chrono::nanoseconds>( |
| 812 | track_end_time - track_start_time) |
| 813 | .count(); |
| 814 | center_intervall_str = "[" + std::to_string(settings.non_center_percent) + "-" + std::to_string(100 - settings.non_center_percent) + "]"; |
| 815 | } |
| 816 | |
| 817 | template <typename StreamType> |
| 818 | void get_summary_table(StreamType &stream, bool use_color = false) |
| 819 | { |
| 820 | BeautifulTable info({ |
| 821 | "Start", |
| 822 | "End", |
| 823 | "time total", |
| 824 | "time ctracked", |
| 825 | "time ctracked %", |
| 826 | }, |
| 827 | use_color, alternate_colors); |
| 828 | info.addRow({BeautifulTable::table_timepoint(tables.start_time), BeautifulTable::table_timepoint(tables.end_time), |
| 829 | BeautifulTable::table_time(static_cast<uint_fast64_t>(tables.time_total.count())), BeautifulTable::table_time(static_cast<uint_fast64_t>(tables.time_ctracked.count())), |
| 830 | BeautifulTable::table_percentage(static_cast<uint_fast64_t>(tables.time_ctracked.count()), static_cast<uint_fast64_t>(tables.time_total.count()))}); |
| 831 | |
| 832 | info.print(stream); |
| 833 | BeautifulTable table({"filename", "function", "line", "calls", "ae" + center_intervall_str + "%", "ae[0-100]%", |
| 834 | "time ae[0-100]", "time a[0-100]"}, |
| 835 | use_color, alternate_colors); |
| 836 | for (const auto &row : tables.summary.rows) |
| 837 | { |
| 838 | table.addRow({BeautifulTable::stable_shortenPath(row.filename), row.function_name, BeautifulTable::table_string(row.line), |
| 839 | BeautifulTable::table_string(row.calls), |
| 840 | BeautifulTable::table_percentage(static_cast<uint_fast64_t>(row.percent_ae_bracket * tables.time_total.count() / 100.0), static_cast<uint_fast64_t>(tables.time_total.count())), |
| 841 | BeautifulTable::table_percentage(static_cast<uint_fast64_t>(row.percent_ae_all * tables.time_total.count() / 100.0), static_cast<uint_fast64_t>(tables.time_total.count())), |
| 842 | BeautifulTable::table_time(static_cast<uint_fast64_t>(row.time_ae_all.count())), |
| 843 | BeautifulTable::table_time(static_cast<uint_fast64_t>(row.time_a_all.count()))}); |
| 844 | } |
| 845 | |
| 846 | table.print(stream); |
| 847 | } |
| 848 | |
| 849 | template <typename StreamType> |
| 850 | void get_detail_table(StreamType &stream, bool use_color = false, bool reverse_vector = false) |
| 851 | { |
| 852 | auto details_copy = tables.details.rows; |
| 853 | if (reverse_vector) |
| 854 | { |
| 855 | std::reverse(details_copy.begin(), details_copy.end()); |
| 856 | } |
| 857 | for (int i = static_cast<int>(details_copy.size()) - 1; i >= 0; i--) |
| 858 | { |
| 859 | const auto &detail = details_copy[i]; |
| 860 | |
| 861 | BeautifulTable info({"filename", "function", "line", "time acc", "sd", "cv", "calls", "threads"}, use_color, default_colors); |
| 862 | info.addRow({BeautifulTable::stable_shortenPath(detail.filename), detail.function_name, BeautifulTable::table_string(detail.line), |
| 863 | BeautifulTable::table_time(static_cast<uint_fast64_t>(detail.time_acc.count())), |
nothing calls this directly
no outgoing calls
no test coverage detected