Merge branch 'for-upstream/platform-x86_tpacpi' of git://repo.or.cz/linux-2.6/linux...
[pandora-kernel.git] / tools / perf / scripts / python / Perf-Trace-Util / lib / Perf / Trace / Util.py
1 # Util.py - Python extension for perf trace, miscellaneous utility code
2 #
3 # Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>
4 #
5 # This software may be distributed under the terms of the GNU General
6 # Public License ("GPL") version 2 as published by the Free Software
7 # Foundation.
8
9 NSECS_PER_SEC    = 1000000000
10
11 def avg(total, n):
12     return total / n
13
14 def nsecs(secs, nsecs):
15     return secs * NSECS_PER_SEC + nsecs
16
17 def nsecs_secs(nsecs):
18     return nsecs / NSECS_PER_SEC
19
20 def nsecs_nsecs(nsecs):
21     return nsecs % NSECS_PER_SEC
22
23 def nsecs_str(nsecs):
24     str = "%5u.%09u" % (nsecs_secs(nsecs), nsecs_nsecs(nsecs)),
25     return str