Reorganisation of the source tree
[ghc-hetmet.git] / utils / parallel / ghc-fool-sort.pl
diff --git a/utils/parallel/ghc-fool-sort.pl b/utils/parallel/ghc-fool-sort.pl
new file mode 100644 (file)
index 0000000..dfa65a1
--- /dev/null
@@ -0,0 +1,23 @@
+##############################################################################
+#
+# Usage: fool-sort 
+#
+# Takes a pure (i.e. no header lines) quasi-parallel profile (a .qp file) from
+# stdin and inserts a counter as second field to force sort not to change the 
+# ordering of lines with the same time stamp. The result is written to stdout.
+#
+##############################################################################
+
+$last_time = 0;
+while (<STDIN>) {
+    ($time, @rest) = split;
+    if ( $time == $last_time ) {
+       $x = ++$count;
+    } else {
+       $x = $count = 0;
+    }
+    print $time, " ", $x, " ", join(' ',@rest), "\n";
+    $last_time = $time;
+}
+
+exit 0;