Bläddra i källkod

Print execution times for all external commands.

Heikki Hokkanen 18 år sedan
förälder
incheckning
7c43e2be12
1 ändrade filer med 9 tillägg och 3 borttagningar
  1. 9
    3
      gitstats

+ 9
- 3
gitstats Visa fil

@@ -14,8 +14,13 @@ GNUPLOT_COMMON = 'set terminal png transparent\nset size 0.5,0.5\n'
14 14
 
15 15
 def getoutput(cmd, quiet = False):
16 16
 	if not quiet:
17
-		print '>> %s' % cmd
17
+		start = time.time()
18
+		print '>> %s' % cmd,
19
+		sys.stdout.flush()
18 20
 	output = commands.getoutput(cmd)
21
+	if not quiet:
22
+		end = time.time()
23
+		print '\r[%.5f] >> %s' % (end - start, cmd)
19 24
 	return output
20 25
 
21 26
 def getkeyssortedbyvalues(dict):
@@ -736,8 +741,9 @@ plot 'lines_of_code.dat' using 1:2 w lines
736 741
 		os.chdir(path)
737 742
 		files = glob.glob(path + '/*.plot')
738 743
 		for f in files:
739
-			print '>> gnuplot %s' % os.path.basename(f)
740
-			os.system('gnuplot %s' % f)
744
+			out = getoutput('gnuplot %s' % f)
745
+			if len(out) > 0:
746
+				print out
741 747
 
742 748
 	def printHeader(self, f):
743 749
 		f.write(