Pārlūkot izejas kodu

tools: remove a huge bottleneck in starpu_trace_state_stats.py

Make calc_stats() linear instead of quadratic is definitely much better.
Samuel Pitoiset 9 gadi atpakaļ
vecāks
revīzija
5c37069d88
1 mainītis faili ar 17 papildinājumiem un 9 dzēšanām
  1. 17 9
      tools/starpu_trace_state_stats.py

+ 17 - 9
tools/starpu_trace_state_stats.py

@@ -91,15 +91,23 @@ class Worker():
 	    if not is_allowed:
 		continue
 
-            if next_event._type == "PushState":
-                self._stack.append(next_event)
-                for j in xrange(i+1, num_events):
-                    next_event = self._events[j]
-                    if next_event._type == "SetState":
-                        break
-            elif next_event._type == "PopState":
-		if not len(self._stack) == 0:
-                    curr_event = self._stack.pop()
+	    if curr_event._type == "SetState":
+		if next_event._type == "PopState":
+		    sys.exit("ERROR: The trace is most likely corrupted "
+			     "because a PopState event has been found just "
+			     "after a SetState!")
+	    elif curr_event._type == "PushState":
+		self._stack.append(curr_event)
+		continue # Will look later to find a PopState event.
+	    elif curr_event._type == "PopState":
+		if len(self._stack) == 0:
+		    sys.exit("ERROR: The trace is most likely corrupted "
+			     "because a PopState event has been found without "
+			     "a PushState!")
+		next_event = curr_event
+		curr_event = self._stack.pop()
+	    else:
+		sys.exit("ERROR: Invalid event type!")
 
             # Compute duration with the next event.
             a = curr_event._start_time