""" cd CobraWorkSpace/Source bin/build-compiler-lib -turbo # then one of these cobra benchmark-compiler.cobra cobra -contracts:none -include-asserts:no -include-nil-checks:no -include-tests:no -optimize benchmark-compiler.cobra time mono --profile=log:report,calldepth=200 benchmark-compiler.exe > profile-`tss`.text time mono --profile=log:calls,alloc,output=output.mlpd,maxframes=8,calldepth=100 benchmark-compiler.exe time mono --profile=log:calls,alloc,output=output-`tss`.mlpd,maxframes=8,calldepth=200 benchmark-compiler.exe time mono --profile=output=output-`tss`.mlpd,calldepth=200 benchmark-compiler.exe # > profile-`tss`.text --method-sort=self mprof-report --traces --method-sort=self output-2013-01-23-21-54-20.mlpd > report.text mprof-report --method-sort=self output-2013-01-23-21-54-20.mlpd > report.text """ use Cobra.Compiler use System.Diagnostics class CustomBackEnd inherits ClrBackEnd def makePhases(phases as IList) base.makePhases(phases) v = false if v, for phase in phases, print phase # .stopAt(phases, Cobra.Compiler.ParsePhase) .stopAfter(phases, Cobra.Compiler.GenerateSharpCodePhase) if v print '--' for phase in phases, print phase def stopAfter(phases as IList, phaseType as Type) newPhases = List() for phase in phases newPhases.add(phase) if phase.typeOf == phaseType, break phases.clear phases.addRange(newPhases) class P const reps = 1 var verbosity = 1 def main print 'Starting' Console.out.flush sw = Stopwatch() trace Stopwatch.isHighResolution sw.start for i in .reps print print 'rep [i+1] / [.reps]' Console.out.flush .run sw.stop elapsed = sw.elapsedMilliseconds avg = elapsed to decimal / .reps trace .reps, elapsed, avg print print 'Total time (ms):', elapsed proc = Process.start('mono', '--version') proc.waitForExit print 'Done.' var _defaultOptions = { 'back-end': 'clr', 'compile': true, 'contracts': 'inline', 'debug': '1', 'include-asserts': true, 'include-nil-checks': true, 'include-tests': true, 'include-traces': true, 'native-compiler': 'auto', 'number': 'decimal', 'reveal-internal-exceptions': true, 'test-runner': 'Cobra.Core.CobraCore.runAllTests', 'timeit': false, # won't take if verbosity == 0 'turbo': true, } def defaultOptions as IDictionary options = _defaultOptions.clone options['verbosity'] = .verbosity return options def run .compileCompiler # .compileGeneticAlgorithm def compileCompiler options = .defaultOptions options['embed-run-time'] = true options['timeit'] = true # needs verbosity = 1 or more further up paths = ['cobra.cobra'] paths.addRange(.readFilesFile('files-to-compile.text')) .compile(options, paths) # TokenDef.printMatchStats def compileGeneticAlgorithm options = .defaultOptions sep = Path.directorySeparatorChar paths = ['..[sep]Samples[sep]GeneticAlgorithm.cobra'] .compile(options, paths) def compile(options as IDictionary, paths as List?) compiler = Compiler(.verbosity) ov = OptionValues() for key, value in options, ov[key] = value compiler.options = ov versionString = 'svn:9999' argParser = ArgParser(versionString, nil) # argParser.parseArgs(paths.clone, out ov, out paths) compiler.commandLineArgParser = argParser compiler.initBackEnd(CustomBackEnd(compiler)) print 'Compiling' try cp = CompileParams() cp.files = for path in paths get FileSpec(path, nil) compiler.compile(cp) catch Cobra.Compiler.StopCompilation compiler.printConsoleMessages print 'Done compiling' def readFilesFile(fileName as String) as String* baseDir = Path.getDirectoryName(fileName) for line in File.readAllLines(fileName) line = line.trim if line.length==0 or line.startsWith('#'), continue if not line.endsWith('.cobra'), line += '.cobra' fileArg = Path.combine(baseDir, line) yield fileArg