Add trace reordering script.
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/utils/trace-reorder.py Fri Jul 03 11:44:52 2009 +0200
1.3 @@ -0,0 +1,45 @@
1.4 +#!/usr/bin/env python
1.5 +# coding: utf-8
1.6 +
1.7 +'''
1.8 +Copyright (C) 2009 Guillaume Seguin <guillaume@segu.in>
1.9 +
1.10 +This program is free software; you can redistribute it and/or
1.11 +modify it under the terms of the GNU General Public License
1.12 +as published by the Free Software Foundation; either version 2
1.13 +of the License, or (at your option) any later version.
1.14 +
1.15 +This program is distributed in the hope that it will be useful,
1.16 +but WITHOUT ANY WARRANTY; without even the implied warranty of
1.17 +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.18 +GNU General Public License for more details.
1.19 +
1.20 +You should have received a copy of the GNU General Public License
1.21 +along with this program; if not, write to the Free Software
1.22 +Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
1.23 +
1.24 +Authors :
1.25 + Guillaume Seguin <guillaume@segu.in>
1.26 +'''
1.27 +
1.28 +import sys
1.29 +
1.30 +if len (sys.argv) != 2:
1.31 + print "Usage : %s ASCIITRACEFILE" % sys.argv[0]
1.32 + raise SystemExit
1.33 +
1.34 +f = open (sys.argv[1])
1.35 +lines = f.readlines ()
1.36 +sets = {}
1.37 +for line in lines:
1.38 + bits = line.split (" ")
1.39 + date, context = bits[1:3]
1.40 + key = float (date), int (context)
1.41 + if key not in sets:
1.42 + sets[key] = []
1.43 + sets[key].append (line)
1.44 +
1.45 +f = open (sys.argv[1], "w")
1.46 +for key in sorted (sets.keys ()):
1.47 + for line in sets[key]:
1.48 + f.write (line)