| 1554 | } |
| 1555 | |
| 1556 | void MainWindow::profileCompiledFzn(const QVector<TimingEntry>& timing, const QVector<PathEntry>& paths) |
| 1557 | { |
| 1558 | typedef QMap<QString,QVector<BracketData*>> CoverageMap; |
| 1559 | CoverageMap ce_coverage; |
| 1560 | |
| 1561 | for (int i=0; i<ui->tabWidget->count(); i++) { |
| 1562 | CodeEditor* ce = qobject_cast<CodeEditor*>(ui->tabWidget->widget(i)); |
| 1563 | if (ce == nullptr) { |
| 1564 | continue; |
| 1565 | } |
| 1566 | auto path = ce->filepath.isEmpty() ? ce->playgroundTempFile : ce->filepath; |
| 1567 | if (!path.endsWith(".mzn")) { |
| 1568 | continue; |
| 1569 | } |
| 1570 | QTextBlock tb = ce->document()->begin(); |
| 1571 | QVector<BracketData*> coverage; |
| 1572 | while (tb.isValid()) { |
| 1573 | BracketData* bd = static_cast<BracketData*>(tb.userData()); |
| 1574 | if (bd==nullptr) { |
| 1575 | bd = new BracketData; |
| 1576 | tb.setUserData(bd); |
| 1577 | } |
| 1578 | bd->d.reset(); |
| 1579 | coverage.push_back(bd); |
| 1580 | tb = tb.next(); |
| 1581 | } |
| 1582 | ce_coverage.insert(path,coverage); |
| 1583 | } |
| 1584 | |
| 1585 | int totalCons=1; |
| 1586 | int totalVars=1; |
| 1587 | int totalTime=1; |
| 1588 | for (auto& it : paths) { |
| 1589 | int min_line_covered = -1; |
| 1590 | CoverageMap::iterator fileMatch; |
| 1591 | for (auto& segment : it.path().segments()) { |
| 1592 | auto tryMatch = ce_coverage.find(segment.filename); |
| 1593 | if (tryMatch != ce_coverage.end()) { |
| 1594 | fileMatch = tryMatch; |
| 1595 | min_line_covered = segment.firstLine; |
| 1596 | } |
| 1597 | } |
| 1598 | if (min_line_covered > 0 && min_line_covered <= fileMatch.value().size()) { |
| 1599 | if (it.constraintIndex() != -1) { |
| 1600 | fileMatch.value()[min_line_covered-1]->d.con++; |
| 1601 | totalCons++; |
| 1602 | } else { |
| 1603 | fileMatch.value()[min_line_covered-1]->d.var++; |
| 1604 | totalVars++; |
| 1605 | } |
| 1606 | } |
| 1607 | } |
| 1608 | for (auto& it : timing) { |
| 1609 | CoverageMap::iterator fileMatch = ce_coverage.find(it.filename()); |
| 1610 | if (fileMatch != ce_coverage.end()) { |
| 1611 | int line_no = it.line(); |
| 1612 | if (line_no > 0 && line_no <= fileMatch.value().size()) { |
| 1613 | fileMatch.value()[line_no-1]->d.ms = it.time(); |
nothing calls this directly
no test coverage detected