File tree Expand file tree Collapse file tree 4 files changed +50
-7
lines changed Expand file tree Collapse file tree 4 files changed +50
-7
lines changed Original file line number Diff line number Diff line change 66/.psc *
77/.purs *
88/.psa *
9+ package-lock.json
Original file line number Diff line number Diff line change @@ -2,9 +2,22 @@ language: node_js
22dist : trusty
33sudo : required
44node_js : stable
5+ env :
6+ - PATH=$HOME/purescript:$PATH
57install :
8+ - 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')
9+ - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
10+ - tar -xvf $HOME/purescript.tar.gz -C $HOME/
11+ - chmod a+x $HOME/purescript
612 - npm install -g bower
713 - npm install
8- - bower install
14+ - bower install --production
915script :
1016 - npm run -s build
17+ - bower install
18+ - npm run -s test
19+ after_success :
20+ - >-
21+ test $TRAVIS_TAG &&
22+ echo $GITHUB_TOKEN | pulp login &&
23+ echo y | pulp publish --no-push
Original file line number Diff line number Diff line change 22 "private" : true ,
33 "scripts" : {
44 "clean" : " rimraf output && rimraf .pulp-cache" ,
5- "build" : " pulp build -- --censor-lib --strict"
5+ "build" : " pulp build -- --censor-lib --strict" ,
6+ "test" : " pulp test"
67 },
78 "devDependencies" : {
89 "pulp" : " ^12.2.0" ,
Original file line number Diff line number Diff line change 77module Performance.Minibench
88 ( bench
99 , benchWith
10+ , benchWith'
11+ , BenchResult
12+ , withUnits
1013 ) where
1114
1215import Prelude hiding (min ,max )
@@ -46,8 +49,31 @@ withUnits t
4649-- |
4750-- | To increase benchmark accuracy by forcing garbage collection before the
4851-- | benchmark is run, node should be invoked with the '--expose-gc' flag.
49- benchWith :: forall a . Int -> (Unit -> a ) -> Effect Unit
52+ benchWith
53+ :: forall a
54+ . Int
55+ -> (Unit -> a )
56+ -> Effect Unit
5057benchWith n f = do
58+ res <- benchWith' n f
59+ log (" mean = " <> withUnits res.mean)
60+ log (" stddev = " <> withUnits res.stdDev)
61+ log (" min = " <> withUnits res.min)
62+ log (" max = " <> withUnits res.max)
63+
64+ type BenchResult =
65+ { mean :: Number
66+ , stdDev :: Number
67+ , min :: Number
68+ , max :: Number
69+ }
70+
71+ benchWith'
72+ :: forall a
73+ . Int
74+ -> (Unit -> a )
75+ -> Effect BenchResult
76+ benchWith' n f = do
5177 sumRef <- Ref .new 0.0
5278 sum2Ref <- Ref .new 0.0
5379 minRef <- Ref .new infinity
@@ -70,10 +96,12 @@ benchWith n f = do
7096 let n' = toNumber n
7197 mean = sum / n'
7298 stdDev = sqrt ((sum2 - n' * mean * mean) / (n' - 1.0 ))
73- log (" mean = " <> withUnits mean)
74- log (" stddev = " <> withUnits stdDev)
75- log (" min = " <> withUnits min')
76- log (" max = " <> withUnits max')
99+ pure
100+ { mean
101+ , stdDev
102+ , min: min'
103+ , max: max'
104+ }
77105
78106-- | Estimate the running time of a function and print a summary to the console,
79107-- | by running the function 1000 times.
You can’t perform that action at this time.
0 commit comments