Wiki

root/cobra/trunk/Source/cobra.cobra

Revision 2478, 1.5 KB (checked in by Charles.Esterbrook, 16 months ago)

Fixed: win-comp.bat is broken with compilation errors.
reported-by:RIGHT_THEN

  • Property svn:eol-style set to native
Line 
1"""
2Any enhancements to this file may require enhancements to
3CobraMain-ObjectExplorer-WinForms.cobra.
4
5These files should be kept as small as reasonably possible.
6"""
7
8class CobraMain
9
10    shared
11
12        pro willTimeIt from var as bool
13        pro runTime from var as TimeSpan?
14        pro compiler from var as Compiler?
15       
16        def main
17            # CobraCore.willCheckAll = false
18
19            sw = System.Diagnostics.Stopwatch()
20            sw.start
21            try
22                CommandLine().run
23            finally
24                sw.stop
25                if _willTimeIt
26                    elapsed = sw.elapsed
27                    didCompile = .compiler is not nil
28                    didRun = .runTime is not nil
29                    if didCompile and didRun
30                        .printTimeIt('total', elapsed)
31                        .printTimeIt('execute', .runTime to !)
32                        .printCompileTimes(elapsed.subtract(.runTime to !))
33                    else if didCompile
34                        .printCompileTimes(elapsed)
35                    else if didRun
36                        .printTimeIt('execute', .runTime to !)
37                    else
38                        .printTimeIt('total', elapsed)
39
40        def printTimeIt(description as String, duration as TimeSpan)
41            print 'timeit [description.padRight(7)] = [duration]' stop
42            if duration.totalSeconds < 2
43                print ' | [duration.totalMilliseconds] ms' stop
44            print
45               
46        def printCompileTimes(elapsed as TimeSpan)
47            .printTimeIt('compile', elapsed)
48            if .compiler, .compiler.printTimingStats(elapsed)
49
50        def printEx(ex as Exception)
51            print
52            if true
53                print ex
54            else
55                print '[ex.getType.name]:'
56                print ex.message
57                if ex.innerException
58                    print 'inner exception:'
59                    .printEx(ex.innerException to !)
60            print
Note: See TracBrowser for help on using the browser.