Skip to content

Instantly share code, notes, and snippets.

@briancavalier
Created March 19, 2013 19: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 briancavalier/cd86eab98fe405b79fed to your computer and use it in GitHub Desktop.
Save briancavalier/cd86eab98fe405b79fed to your computer and use it in GitHub Desktop.
<!doctype html>
<html>
<head>
<title></title>
<script type="text/javascript" src="curl/src/curl.js"></script>
<script type="text/javascript">
curl.config({
packages: {
when: { path: 'when', main: 'when' }
}
});
curl(['when'], function(lib) {
var i, d, start, arr;
arr = [];
for (i = 0; i < 100; i++) {
d = lib.defer();
d.resolve(0);
arr[i] = d.promise;
}
start = Date.now();
for (i = 0; i < 100; i++) {
arr = arr.map(function (p) {
return p.then(f);
});
}
lib.all(arr).then(function (val) {
console.log(Date.now() - start);
}, console.error);
function f(x) {
return x + 1;
}
});
</script>
</head>
<body>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment