From 63f800412fb70bd7b43392907ff3ef61b2d2ff27 Mon Sep 17 00:00:00 2001 From: Irakli Safareli Date: Wed, 13 Dec 2017 00:28:06 +0100 Subject: [PATCH 1/2] add BenchResult --- src/Performance/Minibench.purs | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/src/Performance/Minibench.purs b/src/Performance/Minibench.purs index 31197ed..ab1b7d2 100644 --- a/src/Performance/Minibench.purs +++ b/src/Performance/Minibench.purs @@ -7,6 +7,9 @@ module Performance.Minibench ( bench , benchWith + , benchWith' + , BenchResult + , withUnits ) where import Control.Monad.Eff (Eff, forE) @@ -50,7 +53,26 @@ benchWith . Int -> (Unit -> a) -> Eff (console :: CONSOLE | eff) Unit -benchWith n f = runST do +benchWith n f = do + res <- benchWith' n f + log ("mean = " <> withUnits res.mean) + log ("stddev = " <> withUnits res.stdDev) + log ("min = " <> withUnits res.min) + log ("max = " <> withUnits res.max) + +type BenchResult = + { mean :: Number + , stdDev :: Number + , min :: Number + , max :: Number + } + +benchWith' + :: forall eff a + . Int + -> (Unit -> a) + -> Eff eff BenchResult +benchWith' n f = runST do sumRef <- newSTRef 0.0 sum2Ref <- newSTRef 0.0 minRef <- newSTRef infinity @@ -73,10 +95,12 @@ benchWith n f = runST do let n' = toNumber n mean = sum / n' stdDev = sqrt ((sum2 - n' * mean * mean) / (n' - 1.0)) - log ("mean = " <> withUnits mean) - log ("stddev = " <> withUnits stdDev) - log ("min = " <> withUnits min') - log ("max = " <> withUnits max') + pure + { mean + , stdDev + , min: min' + , max: max' + } -- | Estimate the running time of a function and print a summary to the console, -- | by running the function 1000 times. From 129ec6cb48bc0f6be5e3348dcfd1e1217f6bf4de Mon Sep 17 00:00:00 2001 From: Gary Burgess Date: Tue, 22 May 2018 16:40:43 +0100 Subject: [PATCH 2/2] Update build --- .gitignore | 1 + .travis.yml | 15 ++++++++++++++- package.json | 3 ++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 9623fa5..9121a72 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /.psc* /.purs* /.psa* +package-lock.json diff --git a/.travis.yml b/.travis.yml index fdb744f..5b14646 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,9 +2,22 @@ language: node_js dist: trusty sudo: required node_js: stable +env: + - PATH=$HOME/purescript:$PATH install: + - TAG=$(wget -q -O - https://github.com/purescript/purescript/releases/latest --server-response --max-redirect 0 2>&1 | sed -n -e 's/.*Location:.*tag\///p') + - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz + - tar -xvf $HOME/purescript.tar.gz -C $HOME/ + - chmod a+x $HOME/purescript - npm install -g bower - npm install - - bower install + - bower install --production script: - npm run -s build + - bower install + - npm run -s test +after_success: +- >- + test $TRAVIS_TAG && + echo $GITHUB_TOKEN | pulp login && + echo y | pulp publish --no-push diff --git a/package.json b/package.json index 01da16a..5a4bff0 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,8 @@ "private": true, "scripts": { "clean": "rimraf output && rimraf .pulp-cache", - "build": "pulp build -- --censor-lib --strict" + "build": "pulp build -- --censor-lib --strict", + "test": "pulp test" }, "devDependencies": { "pulp": "^12.2.0",