Skip to content

Instantly share code, notes, and snippets.

@jpedrosa
Created November 29, 2011 20:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jpedrosa/1406209 to your computer and use it in GitHub Desktop.
Save jpedrosa/1406209 to your computer and use it in GitHub Desktop.
$ cat plus.dart
main() {
var count = 0;
for (var i = 0; i < 100000; i++) {
count += i;
}
print(count);
}
$ time dart_release plus.dart
4999950000
real 0m0.119s
user 0m0.088s
sys 0m0.028s
$ frogsh --compile-only --out=plus.js plus.dart
$ time node plus.js
4999950000
real 0m0.067s
user 0m0.060s
sys 0m0.004s
$ cat plus.js
// ********** Library dart:core **************
// ********** Natives dart:core **************
// ********** Code for Object **************
// ********** Code for BadNumberFormatException **************
function BadNumberFormatException() {}
BadNumberFormatException.prototype.toString = function() {
return ("BadNumberFormatException: '" + this._s + "'");
}
// ********** Code for top level **************
function print(obj) {
if (typeof console == 'object') {
if (obj) obj = obj.toString();
console.log(obj);
} else {
write(obj);
write('\n');
}
}
// ********** Library dart:coreimpl **************
// ********** Code for NumImplementation **************
NumImplementation = Number;
// ********** Code for StringImplementation **************
StringImplementation = String;
StringImplementation.prototype.contains = function(pattern, startIndex) {
return this.indexOf(pattern, startIndex) >= 0;
}
// ********** Code for top level **************
// ********** Library plus **************
// ********** Code for top level **************
function main() {
var count = 0;
for (var i = 0;
i < 100000; i = i + 1) {
count = count + i;
}
print(count);
}
main();
$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment