| 930 | } |
| 931 | |
| 932 | void program::perf_report( |
| 933 | std::ostream& os, std::size_t n, parameter_map params, std::size_t batch, bool detailed) const |
| 934 | { |
| 935 | auto& ctx = this->impl->contexts; |
| 936 | // Run once by itself |
| 937 | eval(params); |
| 938 | this->finish(); |
| 939 | // Run and time entire program |
| 940 | std::vector<double> total_vec; |
| 941 | total_vec.reserve(n); |
| 942 | for(std::size_t i = 0; i < n; i++) |
| 943 | { |
| 944 | total_vec.push_back(time<milliseconds>([&] { |
| 945 | eval(params); |
| 946 | this->finish(); |
| 947 | })); |
| 948 | } |
| 949 | std::sort(total_vec.begin(), total_vec.end()); |
| 950 | std::unordered_map<instruction_ref, std::vector<double>> ins_vec; |
| 951 | // Fill the map |
| 952 | generic_eval(*this, ctx, params, [&](auto ins, auto) { |
| 953 | ins_vec[ins].reserve(n); |
| 954 | return argument{ins->get_shape(), nullptr}; |
| 955 | }); |
| 956 | |
| 957 | // Run and time each instruction |
| 958 | for(std::size_t i = 0; i < n; i++) |
| 959 | { |
| 960 | generic_eval(*this, ctx, params, [&](auto ins, auto f) { |
| 961 | argument result; |
| 962 | ins_vec[ins].push_back(time<milliseconds>([&] { |
| 963 | result = f(); |
| 964 | this->impl->contexts[ins->get_target_id()].finish(); |
| 965 | })); |
| 966 | return result; |
| 967 | }); |
| 968 | } |
| 969 | for(auto&& p : ins_vec) |
| 970 | std::sort(p.second.begin(), p.second.end()); |
| 971 | // Run and time implicit overhead |
| 972 | std::vector<double> overhead_vec; |
| 973 | overhead_vec.reserve(n); |
| 974 | for(std::size_t i = 0; i < n; i++) |
| 975 | { |
| 976 | overhead_vec.push_back(time<milliseconds>([&] { dry_run(params); })); |
| 977 | } |
| 978 | double total_time = common_average(total_vec); |
| 979 | double min_time = total_vec.front(); |
| 980 | double max_time = total_vec.back(); |
| 981 | double mean_time = mean(total_vec); |
| 982 | double median_time = median(total_vec); |
| 983 | double percentile_90_time = percentile(total_vec, 0.90); |
| 984 | double percentile_95_time = percentile(total_vec, 0.95); |
| 985 | double percentile_99_time = percentile(total_vec, 0.99); |
| 986 | double rate = 1000.0 / total_time; |
| 987 | double overhead_time = common_average(overhead_vec); |
| 988 | double overhead_percent = overhead_time * 100.0 / total_time; |
| 989 | double total_instruction_time = 0.0; |
no test coverage detected