# Util.py - Python extension for perf trace, miscellaneous utility code## Copyright (C) 2010 by Tom Zanussi <tzanussi@gmail.com>## This software may be distributed under the terms of the GNU General# Public License ("GPL") version 2 as published by the Free Software# Foundation.NSECS_PER_SEC=1000000000defavg(total,n):returntotal/ndefnsecs(secs,nsecs):returnsecs*NSECS_PER_SEC+nsecsdefnsecs_secs(nsecs):returnnsecs/NSECS_PER_SECdefnsecs_nsecs(nsecs):returnnsecs%NSECS_PER_SECdefnsecs_str(nsecs):str="%5u.%09u"%(nsecs_secs(nsecs),nsecs_nsecs(nsecs)),returnstr