MCPcopy Create free account
hub / github.com/MiniZinc/MiniZincIDE / getHeatMapUrl

Function getHeatMapUrl

cp-profiler/src/cpprofiler/conductor.cpp:536–587  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

534}
535
536static std::string getHeatMapUrl(const NameMap &nm,
537 const std::unordered_map<int, int> &con_counts,
538 int max_count)
539{
540 /// get heat map
541
542 std::unordered_map<std::string, int> loc_intensity;
543
544 for (const auto& it : con_counts)
545 {
546 const auto con = std::to_string(it.first);
547 const auto count = it.second;
548
549 const auto &path = nm.getPath(con);
550
551 const auto path_head_elements = utils::getPathPair(path, true).model_level;
552
553 if (path_head_elements.empty())
554 continue;
555
556 const auto path_head = path_head_elements.back();
557
558 const auto location_etc = utils::split(path_head, utils::minor_sep);
559
560 // print("path: {}", path);
561
562 // for (auto e : new_loc) {
563 // print("element: {}", e);
564 // }
565
566 /// path plus four ints
567 if (location_etc.size() < 5)
568 continue;
569
570 std::vector<std::string> new_loc(location_etc.begin(), location_etc.begin() + 5);
571
572 int val = static_cast<int>(std::floor(count * (255.0 / max_count)));
573
574 const auto loc_str = utils::join(new_loc, utils::minor_sep);
575
576 loc_intensity[loc_str] = std::max(loc_intensity[loc_str], val);
577 }
578
579 /// highlight url
580 std::stringstream url;
581 url << "highlight://?";
582
583 for (auto it : loc_intensity)
584 url << it.first << utils::minor_sep << it.second << ";";
585
586 return url.str();
587}
588
589void Conductor::computeHeatMap(ExecID eid, std::vector<NodeID> ns)
590{

Callers 1

computeHeatMapMethod · 0.85

Calls 7

to_stringFunction · 0.85
getPathPairFunction · 0.85
splitFunction · 0.85
joinFunction · 0.85
strMethod · 0.80
sizeMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected