Created
March 16, 2016 03:59
-
-
Save evanw/ded36bd53077b9d5ee89 to your computer and use it in GitHub Desktop.
Compiler benchmark
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[submodule "skew"] | |
path = skew | |
url = [email protected]:evanw/skew.git | |
[submodule "typescript"] | |
path = typescript | |
url = https://git01.codeplex.com/typescript | |
[submodule "coffeescript"] | |
path = coffeescript | |
url = [email protected]:jashkenas/coffeescript.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"skew": "0.7.38" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Skew (C++) 140 ms | |
Skew (JS) 956 ms | |
TypeScript 8639 ms | |
CoffeeScript 1895 ms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
var child_process = require('child_process'); | |
var fs = require('fs'); | |
var commands = [ | |
{ | |
name: 'Skew (C++)', | |
dir: 'skew', | |
prep: 'mkdir out', | |
exec: [ | |
'../node_modules/.bin/skewc', | |
'src/backend/cplusplus.sk', | |
'src/backend/csharp.sk', | |
'src/backend/emitter.sk', | |
'src/backend/javascript.sk', | |
'src/backend/lisptree.sk', | |
'src/backend/sourcemap.sk', | |
'src/core/content.sk', | |
'src/core/node.sk', | |
'src/core/operators.sk', | |
'src/core/support.sk', | |
'src/core/symbol.sk', | |
'src/frontend/lexer.sk', | |
'src/frontend/log.sk', | |
'src/frontend/parser.sk', | |
'src/frontend/pratt.sk', | |
'src/frontend/range.sk', | |
'src/frontend/source.sk', | |
'src/frontend/token.sk', | |
'src/frontend/version.sk', | |
'src/middle/callgraph.sk', | |
'src/middle/compiler.sk', | |
'src/middle/controlflow.sk', | |
'src/middle/folding.sk', | |
'src/middle/globalizing.sk', | |
'src/middle/ide.sk', | |
'src/middle/inlining.sk', | |
'src/middle/interfaceremoval.sk', | |
'src/middle/lambdaconversion.sk', | |
'src/middle/library.sk', | |
'src/middle/librarycpp.sk', | |
'src/middle/librarycs.sk', | |
'src/middle/libraryjs.sk', | |
'src/middle/merging.sk', | |
'src/middle/motion.sk', | |
'src/middle/renaming.sk', | |
'src/middle/resolving.sk', | |
'src/middle/scope.sk', | |
'src/middle/shaking.sk', | |
'src/middle/type.sk', | |
'src/middle/typecache.sk', | |
'src/middle/unicode.sk', | |
'src/lib/timestamp.sk', | |
'src/driver/terminal.sk', | |
'src/driver/options.sk', | |
'src/lib/io.sk', | |
'src/lib/terminal.sk', | |
'--inline-functions', | |
'--verbose', | |
'--message-limit=0', | |
'--output-file=out/skewc.min.js', | |
'--release', | |
].join(' ') | |
}, | |
{ | |
name: 'Skew (JS)', | |
dir: 'skew', | |
prep: 'mkdir out', | |
exec: [ | |
'node', | |
'out/skewc.min.js', | |
'src/backend/cplusplus.sk', | |
'src/backend/csharp.sk', | |
'src/backend/emitter.sk', | |
'src/backend/javascript.sk', | |
'src/backend/lisptree.sk', | |
'src/backend/sourcemap.sk', | |
'src/core/content.sk', | |
'src/core/node.sk', | |
'src/core/operators.sk', | |
'src/core/support.sk', | |
'src/core/symbol.sk', | |
'src/frontend/lexer.sk', | |
'src/frontend/log.sk', | |
'src/frontend/parser.sk', | |
'src/frontend/pratt.sk', | |
'src/frontend/range.sk', | |
'src/frontend/source.sk', | |
'src/frontend/token.sk', | |
'src/frontend/version.sk', | |
'src/middle/callgraph.sk', | |
'src/middle/compiler.sk', | |
'src/middle/controlflow.sk', | |
'src/middle/folding.sk', | |
'src/middle/globalizing.sk', | |
'src/middle/ide.sk', | |
'src/middle/inlining.sk', | |
'src/middle/interfaceremoval.sk', | |
'src/middle/lambdaconversion.sk', | |
'src/middle/library.sk', | |
'src/middle/librarycpp.sk', | |
'src/middle/librarycs.sk', | |
'src/middle/libraryjs.sk', | |
'src/middle/merging.sk', | |
'src/middle/motion.sk', | |
'src/middle/renaming.sk', | |
'src/middle/resolving.sk', | |
'src/middle/scope.sk', | |
'src/middle/shaking.sk', | |
'src/middle/type.sk', | |
'src/middle/typecache.sk', | |
'src/middle/unicode.sk', | |
'src/lib/timestamp.sk', | |
'src/driver/terminal.sk', | |
'src/driver/options.sk', | |
'src/lib/io.sk', | |
'src/lib/terminal.sk', | |
'--inline-functions', | |
'--verbose', | |
'--message-limit=0', | |
'--output-file=out/skewc.min.js', | |
'--release', | |
] | |
}, | |
{ | |
name: 'TypeScript (JS)', | |
dir: 'typescript', | |
prep: 'npm install', | |
exec: [ | |
'node', | |
'bin/tsc.js', | |
'-removeComments', | |
'-propagateEnumConstants', | |
'-declaration', | |
'-noImplicitAny', | |
'--module', | |
'commonjs', | |
'src/compiler/ast.ts', | |
'src/compiler/astHelpers.ts', | |
'src/compiler/astWalker.ts', | |
'src/compiler/base64.ts', | |
'src/compiler/bloomFilter.ts', | |
'src/compiler/declarationEmitter.ts', | |
'src/compiler/diagnostics.ts', | |
'src/compiler/document.ts', | |
'src/compiler/emitter.ts', | |
'src/compiler/enumerator.ts', | |
'src/compiler/flags.ts', | |
'src/compiler/hashTable.ts', | |
'src/compiler/identifierWalker.ts', | |
'src/compiler/pathUtils.ts', | |
'src/compiler/precompile.ts', | |
'src/compiler/process.ts', | |
'src/compiler/references.ts', | |
'src/compiler/referenceResolution.ts', | |
'src/compiler/referenceResolver.ts', | |
'src/compiler/settings.ts', | |
'src/compiler/sourceMapping.ts', | |
'src/compiler/syntaxTreeToAstVisitor.ts', | |
'src/compiler/types.ts', | |
'src/compiler/core/arrayUtilities.ts', | |
'src/compiler/core/bitVector.ts', | |
'src/compiler/core/bitMatrix.ts', | |
'src/compiler/core/constants.ts', | |
'src/compiler/core/debug.ts', | |
'src/compiler/core/diagnosticCore.ts', | |
'src/compiler/core/diagnosticCategory.ts', | |
'src/compiler/core/diagnosticInfo.ts', | |
'src/compiler/core/environment.ts', | |
'src/compiler/core/errors.ts', | |
'src/compiler/core/hash.ts', | |
'src/compiler/core/hashTable.ts', | |
'src/compiler/core/integerUtilities.ts', | |
'src/compiler/core/lineAndCharacter.ts', | |
'src/compiler/core/lineMap.ts', | |
'src/compiler/core/linePosition.ts', | |
'src/compiler/core/mathPrototype.ts', | |
'src/compiler/core/references.ts', | |
'src/compiler/core/require.ts', | |
'src/compiler/core/stringTable.ts', | |
'src/compiler/core/stringUtilities.ts', | |
'src/compiler/core/timer.ts', | |
'src/compiler/resources/diagnosticCode.generated.ts', | |
'src/compiler/resources/diagnosticInformationMap.generated.ts', | |
'src/compiler/resources/references.ts', | |
'src/compiler/syntax/characterInfo.ts', | |
'src/compiler/syntax/constants.ts', | |
'src/compiler/syntax/depthLimitedWalker.ts', | |
'src/compiler/syntax/formattingOptions.ts', | |
'src/compiler/syntax/indentation.ts', | |
'src/compiler/syntax/languageVersion.ts', | |
'src/compiler/syntax/parseOptions.ts', | |
'src/compiler/syntax/parser.ts', | |
'src/compiler/syntax/positionedElement.ts', | |
'src/compiler/syntax/positionTrackingWalker.ts', | |
'src/compiler/syntax/references.ts', | |
'src/compiler/syntax/scanner.ts', | |
'src/compiler/syntax/scannerUtilities.generated.ts', | |
'src/compiler/syntax/separatedSyntaxList.ts', | |
'src/compiler/syntax/slidingWindow.ts', | |
'src/compiler/syntax/strings.ts', | |
'src/compiler/syntax/syntax.ts', | |
'src/compiler/syntax/syntaxDedenter.ts', | |
'src/compiler/syntax/syntaxElement.ts', | |
'src/compiler/syntax/syntaxFactory.generated.ts', | |
'src/compiler/syntax/syntaxFacts.ts', | |
'src/compiler/syntax/syntaxFacts2.ts', | |
'src/compiler/syntax/syntaxIndenter.ts', | |
'src/compiler/syntax/syntaxInformationMap.ts', | |
'src/compiler/syntax/syntaxIndenter.ts', | |
'src/compiler/syntax/syntaxKind.ts', | |
'src/compiler/syntax/syntaxList.ts', | |
'src/compiler/syntax/syntaxNode.ts', | |
'src/compiler/syntax/syntaxNodeInvariantsChecker.ts', | |
'src/compiler/syntax/syntaxNodeOrToken.ts', | |
'src/compiler/syntax/syntaxNodes.generated.ts', | |
'src/compiler/syntax/syntaxRewriter.generated.ts', | |
'src/compiler/syntax/syntaxToken.generated.ts', | |
'src/compiler/syntax/syntaxToken.ts', | |
'src/compiler/syntax/syntaxTokenReplacer.ts', | |
'src/compiler/syntax/syntaxTree.ts', | |
'src/compiler/syntax/syntaxTrivia.ts', | |
'src/compiler/syntax/syntaxTriviaList.ts', | |
'src/compiler/syntax/syntaxUtilities.ts', | |
'src/compiler/syntax/syntaxVisitor.generated.ts', | |
'src/compiler/syntax/syntaxWalker.generated.ts', | |
'src/compiler/syntax/unicode.ts', | |
'src/compiler/text/characterCodes.ts', | |
'src/compiler/text/lineMap.ts', | |
'src/compiler/text/references.ts', | |
'src/compiler/text/scriptSnapshot.ts', | |
'src/compiler/text/text.ts', | |
'src/compiler/text/textChangeRange.ts', | |
'src/compiler/text/textFactory.ts', | |
'src/compiler/text/textLine.ts', | |
'src/compiler/text/textSpan.ts', | |
'src/compiler/text/textUtilities.ts', | |
'src/compiler/typecheck/pullDeclCollection.ts', | |
'src/compiler/typecheck/pullDecls.ts', | |
'src/compiler/typecheck/pullFlags.ts', | |
'src/compiler/typecheck/pullHelpers.ts', | |
'src/compiler/typecheck/pullSemanticInfo.ts', | |
'src/compiler/typecheck/pullSymbolBinder.ts', | |
'src/compiler/typecheck/pullSymbols.ts', | |
'src/compiler/typecheck/pullTypeResolution.ts', | |
'src/compiler/typecheck/pullTypeResolutionContext.ts', | |
'src/compiler/typecheck/pullTypeInstantiation.ts', | |
'src/compiler/typescript.ts', | |
'src/compiler/io.ts', | |
'src/compiler/optionsParser.ts', | |
'src/compiler/tsc.ts', | |
'-out', | |
'built/local/tsc.js', | |
] | |
}, | |
{ | |
name: 'CoffeeScript (JS)', | |
dir: 'coffeescript', | |
prep: 'npm install', | |
exec: [ | |
'node', | |
'bin/coffee', | |
'-c', | |
'-o', | |
'lib/coffee-script', | |
'src/browser.coffee', | |
'src/cake.coffee', | |
'src/coffee-script.coffee', | |
'src/command.coffee', | |
'src/grammar.coffee', | |
'src/helpers.coffee', | |
'src/index.coffee', | |
'src/lexer.coffee', | |
'src/nodes.coffee', | |
'src/optparse.coffee', | |
'src/register.coffee', | |
'src/repl.coffee', | |
'src/rewriter.coffee', | |
'src/scope.litcoffee', | |
'src/sourcemap.litcoffee', | |
] | |
}, | |
]; | |
commands.forEach(function(command) { | |
// Run the prep command | |
try { | |
child_process.execSync(command.prep, { cwd: command.dir, stdio: 'pipe' }); | |
} catch (e) { | |
} | |
// Take the best time out of a few tries | |
var best = Infinity; | |
for (var i = 0; i < 3; i++) { | |
// Why doesn't execSync() return stderr? WTF? | |
child_process.execSync('(time ' + command.exec + ') 2>../stderr.txt', { cwd: command.dir, stdio: 'pipe' }); | |
var stderr = fs.readFileSync('stderr.txt', 'utf8'); | |
fs.unlinkSync('stderr.txt'); | |
// Take the minimum time | |
var time = +/real\t0m([\.\d]+)s/.exec(stderr)[1]; | |
best = Math.min(best, time); | |
} | |
// Report time | |
console.log(command.name + '\t' + (best * 1000) + ' ms'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment