| 562 | }; |
| 563 | |
| 564 | class EventGroup |
| 565 | { |
| 566 | public: |
| 567 | void calculateStats(unsigned int non_center_percent, const std::unordered_map<int_fast64_t, const Event *> &events_map, const std::unordered_map<int_fast64_t, std::vector<int_fast64_t>> &child_graph) |
| 568 | { |
| 569 | if (all_events.size() == 0) |
| 570 | return; |
| 571 | |
| 572 | auto all_events_simple = create_simple_events(all_events); |
| 573 | std::sort(OPT_EXEC_POLICY all_events_simple.begin(), all_events_simple.end(), cmp_simple_event_by_duration_asc); |
| 574 | all_cnt = static_cast<unsigned int>(all_events_simple.size()); |
| 575 | const double factor = (1.0 / static_cast<double>(all_cnt)); |
| 576 | |
| 577 | auto all_child_events_simple = load_child_events_simple(all_events_simple, events_map, child_graph); |
| 578 | |
| 579 | all_time_acc = sum_field(all_events_simple, &Simple_Event::duration); |
| 580 | |
| 581 | const double all_mean = all_time_acc * factor; |
| 582 | if (std::fpclassify(all_mean) == FP_ZERO) |
| 583 | return; |
| 584 | |
| 585 | all_st = calculate_std_dev_field(all_events_simple, &Simple_Event::duration, all_mean); // std::sqrt(all_variance); |
| 586 | all_cv = all_st / all_mean; |
| 587 | |
| 588 | all_thread_cnt = static_cast<unsigned int>(get_distinct_field_values(all_events, &Event::thread_id).size()); |
| 589 | unsigned int amount_non_center = all_cnt * non_center_percent / 100; |
| 590 | |
| 591 | fastest_range = non_center_percent; |
| 592 | slowest_range = 100 - non_center_percent; |
| 593 | |
| 594 | std::vector<Simple_Event> fastest_events_simple, slowest_events_simple, center_events_simple; |
| 595 | fastest_events_simple.reserve(amount_non_center); |
| 596 | slowest_events_simple.reserve(amount_non_center); |
| 597 | if (all_cnt > 2) |
| 598 | center_events_simple.reserve(all_cnt - 2 * amount_non_center); |
| 599 | |
| 600 | for (unsigned int i = 0; i < all_events_simple.size(); i++) |
| 601 | { |
| 602 | if (i < amount_non_center) |
| 603 | { |
| 604 | fastest_events_simple.push_back(all_events_simple[i]); |
| 605 | } |
| 606 | else if (i >= all_cnt - amount_non_center) |
| 607 | { |
| 608 | slowest_events_simple.push_back(all_events_simple[i]); |
| 609 | } |
| 610 | else |
| 611 | { |
| 612 | center_events_simple.push_back(all_events_simple[i]); |
| 613 | } |
| 614 | } |
| 615 | if (amount_non_center > 0) |
| 616 | { |
| 617 | // fastest |
| 618 | fastest_min = fastest_events_simple[0].duration; |
| 619 | fastest_mean = sum_field(fastest_events_simple, &Simple_Event::duration) / static_cast<double>(amount_non_center); |
| 620 | |
| 621 | // slowest |
nothing calls this directly
no outgoing calls
no test coverage detected