Ticket #182: timeitBug.patch
File timeitBug.patch, 3.4 KB (added by hopscc, 15 years ago) |
---|
-
Source/CommandLine.cobra
738 738 if .options.boolValue('compile') # maybe changed by compiler directive 739 739 return 740 740 741 sw = System.Diagnostics.Stopwatch() 742 sw.start 743 741 744 exeFileName as String? = nil 742 745 runArgs = .options.getStringList('run-args') 743 746 # TODO: what's this? … … 759 762 if 'elevation' in exc.message 760 763 print 'If you are on Windows Vista, using an admin or power user account may avoid this problem.' 761 764 Environment.exit(1) 762 765 sw.stop 766 CobraMain.runTime = sw.elapsed 767 763 768 def doHelp 764 769 .doAbout 765 770 print '' -
Source/cobra.cobra
3 3 shared 4 4 5 5 pro willTimeIt from var as bool 6 pro runTime from var as TimeSpan 6 7 pro linesCompiled from var as int 7 8 pro nodesCompiled from var as int 8 9 pro tokensCompiled from var as int … … 17 18 finally 18 19 sw.stop 19 20 if _willTimeIt 20 print 'timeit = [sw.elapsed]' 21 if sw.elapsed.totalSeconds < 2 22 print 'timeit = [sw.elapsedMilliseconds] ms' 21 elapsed = sw.elapsed 22 print 'timeit = [elapsed]' 23 if .linesCompiled + .nodesCompiled + .tokensCompiled 24 elapsed = elapsed.subtract(.runTime) 25 .printCompileTimes(elapsed) 23 26 24 secs = sw.elapsedMilliseconds / 1_000.0 25 lps = .linesCompiled / secs 26 print '[.linesCompiled] lines compiled = [lps:F2] lines/sec' 27 nps = .nodesCompiled / secs 28 print '[.nodesCompiled] nodes compiled = [nps:F2] nodes/sec' 29 tps = .tokensCompiled / secs 30 print '[.tokensCompiled] tokens compiled = [tps:F2] tokens/sec' 27 def printCompileTimes(elapsed as TimeSpan) 28 print 'ccOnly = [elapsed]' 29 if elapsed.totalSeconds < 2 30 print 'timeit = [elapsed.milliseconds] ms' 31 31 32 secs = elapsed.totalMilliseconds / 1_000 33 if .linesCompiled 34 lps = .linesCompiled / secs 35 print '[.linesCompiled] lines compiled = [lps:F2] lines/sec' 36 if .nodesCompiled 37 nps = .nodesCompiled / secs 38 print '[.nodesCompiled] nodes compiled = [nps:F2] nodes/sec' 39 if .tokensCompiled 40 tps = .tokensCompiled / secs 41 print '[.tokensCompiled] tokens compiled = [tps:F2] tokens/sec' 42 32 43 def printEx(ex as Exception) 33 44 print 34 45 if true -
Tests/700-command-line/113-timeit.cobra
1 class Timeit 2 3 def main is shared 4 Timeit().runTest 5 6 def runTest 7 sub = '110-hello.cobra' 8 9 output = .runCobraExe('[sub]') 10 try 11 assert 'timeit =' not in output 12 assert 'Hello' in output 13 success 14 print 'No timeit OK' 15 16 output = .runCobraExe('-timeit [sub]') 17 try 18 assert 'timeit =' in output 19 assert 'ccOnly =' in output 20 assert 'lines compiled' in output 21 assert 'nodes compiled' in output 22 assert 'tokens compiled' in output 23 assert 'Hello' in output 24 success 25 print '-timeit OK' 26 27 def runCobraExe(args as String) as String 28 p as System.Diagnostics.Process? 29 return CobraCore.runCobraExe(args, out p) 30