diff --git a/README.md b/README.md index d3ec875a..4748e6bf 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,19 @@ +Stopify: CPS and Yield End-of-Life +================================== + +This repository has Stopify's CPS and generator based implementations of +continuations. We find that they are significantly slower than the approach +that Stopify now uses. To observe this, run the following script to time CPS +and generator based continuations: + + yarn install + yarn run build + ./compare.sh + +The script builds and runs `./triangle.js` without ever yielding. You'll find +that it is 3x (CPS) or 2x (generator) slower than compiling with Stopify +"jumper"-based strategies. + ## Stopify [![Build Status](http://23.20.114.147:5000/buildStatus/icon?job=stopify-build/master)](http://23.20.114.147:5000/job/stopify-build/job/master/) Web-based programming environments lack many basic features that programmers diff --git a/compare.sh b/compare.sh new file mode 100755 index 00000000..257961ef --- /dev/null +++ b/compare.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +echo "**** CPS ****" +./bin/stopify --optimize -t cps -i triangle.js > triangle.cps.js +node --harmony_tailcalls triangle.cps.js + +echo "**** Generators ****" +./bin/stopify --optimize -t yield -i triangle.js > triangle.yield.js +node --harmony_tailcalls triangle.yield.js \ No newline at end of file diff --git a/triangle.js b/triangle.js new file mode 100644 index 00000000..5c2d150f --- /dev/null +++ b/triangle.js @@ -0,0 +1,15 @@ +'use strict'; + +function triangle(n) { + if (n === 0) { + return 1; + } + else { + return n + triangle(n - 1); + } +} + +var r = 0; +for (var i = 0; i < 150000; i++) { + r = (i % 2) + triangle(1000); +} diff --git a/yarn.lock b/yarn.lock index c22ce709..a0357bb6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2719,7 +2719,7 @@ ms@2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8" -nan@>=2.0.0, nan@^2.3.0: +nan@^2.3.0: version "2.6.2" resolved "https://registry.yarnpkg.com/nan/-/nan-2.6.2.tgz#e4ff34e6c95fdfb5aecc08de6596f43605a7db45" @@ -3508,12 +3508,6 @@ slash@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55" -sleep@3.0.x: - version "3.0.1" - resolved "https://registry.yarnpkg.com/sleep/-/sleep-3.0.1.tgz#be4d17c579360e07e04ed8172ba2b10a69054df3" - dependencies: - nan ">=2.0.0" - sntp@1.x.x: version "1.0.9" resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"