Commit 7bb05b40 authored by Jens Korinth's avatar Jens Korinth
Browse files

Closes #50 - Timing Report: Reports false max delay path

* TimingReport would report _first_ max delay path; but there can be
  many, they are ordered by clock in the report
* added RepSeqMatcher to extend SequenceMatcher for Seq[T]
* sorted paths by slack and picked the ones with minimal slack (max
  delay path) and maximal slack (min delay path)
* also fixes minDelayPath, which is pretty useless, however
parent a1dc2f2e
...@@ -21,7 +21,7 @@ ...@@ -21,7 +21,7 @@
* @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de) * @authors J. Korinth, TU Darmstadt (jk@esa.cs.tu-darmstadt.de)
**/ **/
package de.tu_darmstadt.cs.esa.tapasco.reports package de.tu_darmstadt.cs.esa.tapasco.reports
import de.tu_darmstadt.cs.esa.tapasco.util.SequenceMatcher import de.tu_darmstadt.cs.esa.tapasco.util._
import java.nio.file.Path import java.nio.file.Path
import scala.io.Source import scala.io.Source
...@@ -52,7 +52,7 @@ object TimingReport { ...@@ -52,7 +52,7 @@ object TimingReport {
)(cons = ms => ms(2).group(1).toDouble) )(cons = ms => ms(2).group(1).toDouble)
/** Extracts the maximal delay path. **/ /** Extracts the maximal delay path. **/
private def maxDelayPathMatcher: SequenceMatcher[TimingPath] = new SequenceMatcher( private def maxDelayPathMatcher: RepSeqMatcher[TimingPath] = new RepSeqMatcher(
"""^Max Delay Path.*""".r, """^Max Delay Path.*""".r,
""".*""".r, """.*""".r,
"""^Slack[^:]*:\s*(-?\d+\.\d*).*""".r, """^Slack[^:]*:\s*(-?\d+\.\d*).*""".r,
...@@ -62,7 +62,7 @@ object TimingReport { ...@@ -62,7 +62,7 @@ object TimingReport {
)(true, ms => TimingPath(ms(3).group("source"), ms(5).group(1), ms(2).group(1).toDouble)) )(true, ms => TimingPath(ms(3).group("source"), ms(5).group(1), ms(2).group(1).toDouble))
/** Extracts the minimal delay path. **/ /** Extracts the minimal delay path. **/
private def minDelayPathMatcher: SequenceMatcher[TimingPath] = new SequenceMatcher( private def minDelayPathMatcher: RepSeqMatcher[TimingPath] = new RepSeqMatcher(
"""^Min Delay Path.*""".r, """^Min Delay Path.*""".r,
""".*""".r, """.*""".r,
"""^Slack[^:]*:\s*(-?\d+\.\d*).*""".r, """^Slack[^:]*:\s*(-?\d+\.\d*).*""".r,
...@@ -94,8 +94,8 @@ object TimingReport { ...@@ -94,8 +94,8 @@ object TimingReport {
file = sr, file = sr,
worstNegativeSlack = wns.result.get, worstNegativeSlack = wns.result.get,
dataPathDelay = dpd.result.get, dataPathDelay = dpd.result.get,
maxDelayPath = max.result.get, maxDelayPath = max.result.get.sortBy(_.slack).head,
minDelayPath = min.result.get, minDelayPath = min.result.get.sortBy(_.slack).last,
timingMet = wns.result.get >= -0.3 timingMet = wns.result.get >= -0.3
)) ))
} else { None } } else { None }
......
...@@ -49,3 +49,20 @@ private[tapasco] class SequenceMatcher[T](ors : Regex*)(implicit mustMatchEveryL ...@@ -49,3 +49,20 @@ private[tapasco] class SequenceMatcher[T](ors : Regex*)(implicit mustMatchEveryL
} }
} }
} }
/** Repeats a [[SequenceMatcher]] to generate a Seq[T]. */
private[tapasco] class RepSeqMatcher[T](ors: Regex*)(implicit mustMatchEveryLine: Boolean = false,
cons: Seq[Match] => T = identity[Seq[Match]] _) {
private var matcher = new SequenceMatcher(ors:_*)(mustMatchEveryLine, cons)
private val _result = new scala.collection.mutable.ArrayBuffer[T]()
def update(line: String): Boolean = {
matcher.update(line)
if (matcher.matched) {
_result += matcher.result.get
matcher = new SequenceMatcher(ors:_*)(mustMatchEveryLine, cons)
}
matcher.matched
}
def result: Option[Seq[T]] = if (_result.isEmpty) None else Some(_result.toSeq)
def matched: Boolean = _result.nonEmpty
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment