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 6
6
/.psc *
7
7
/.purs *
8
8
/.psa *
9
+ package-lock.json
Original file line number Diff line number Diff line change @@ -2,9 +2,22 @@ language: node_js
2
2
dist : trusty
3
3
sudo : required
4
4
node_js : stable
5
+ env :
6
+ - PATH=$HOME/purescript:$PATH
5
7
install :
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
6
12
- npm install -g bower
7
13
- npm install
8
- - bower install
14
+ - bower install --production
9
15
script :
10
16
- 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 2
2
"private" : true ,
3
3
"scripts" : {
4
4
"clean" : " rimraf output && rimraf .pulp-cache" ,
5
- "build" : " pulp build -- --censor-lib --strict"
5
+ "build" : " pulp build -- --censor-lib --strict" ,
6
+ "test" : " pulp test"
6
7
},
7
8
"devDependencies" : {
8
9
"pulp" : " ^12.2.0" ,
Original file line number Diff line number Diff line change 7
7
module Performance.Minibench
8
8
( bench
9
9
, benchWith
10
+ , benchWith'
11
+ , BenchResult
12
+ , withUnits
10
13
) where
11
14
12
15
import Prelude hiding (min ,max )
@@ -46,8 +49,31 @@ withUnits t
46
49
-- |
47
50
-- | To increase benchmark accuracy by forcing garbage collection before the
48
51
-- | 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
50
57
benchWith 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
51
77
sumRef <- Ref .new 0.0
52
78
sum2Ref <- Ref .new 0.0
53
79
minRef <- Ref .new infinity
@@ -70,10 +96,12 @@ benchWith n f = do
70
96
let n' = toNumber n
71
97
mean = sum / n'
72
98
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
+ }
77
105
78
106
-- | Estimate the running time of a function and print a summary to the console,
79
107
-- | by running the function 1000 times.
You can’t perform that action at this time.
0 commit comments