on master help sign in
Add GHCJS support
commitc86b6734f58cd90797b1a3a6d21a74d115a6e4d4 authorHarendra Kumar <harendra.kumar@gmail.com> dateThu 10 Jan 2019, 05:36 (8 years ago) parentcbff63f
5 files changed+65−9
Changelog.md+6 cabal.project.ghcjs+12 jsbits/clock.js+6 streamly.cabal+5−2 test/MaxRate.hs+36−7
Changelog.md+6
@@ -1,3 +1,9 @@
1+## Unreleased
2+
3+### Enhancements
4+
5+* Add GHCJS support
6+
17## 0.6.0
28
39### Breaking changes
cabal.project.ghcjsnew file+12
@@ -0,0 +1,12 @@
1+compiler: ghcjs
2+packages: streamly.cabal
3+
4+source-repository-package
5+ type: git
6+ location: https://github.com/ghcjs/ghcjs-base
7+ tag: b8d51f65ae1921b2f031710bf75e17f216de442a
8+
9+source-repository-package
10+ type: git
11+ location: https://github.com/harendra-kumar/hs-gauge
12+ tag: 603dcf8c48f35e8a1ab3fc9838fbcde391bc842b
jsbits/clock.jsnew file+6
@@ -0,0 +1,6 @@
1+/* Hack! Supporting code for "clock" package
2+ * "hspec" depends on clock.
3+ */
4+function h$hs_clock_darwin_gettime(when, p_d, p_o) {
5+ h$clock_gettime(when, p_d, p_o);
6+}
streamly.cabal+5−2
@@ -210,6 +210,7 @@ library
210210test-suite test
211211 type: exitcode-stdio-1.0
212212 main-is: Main.hs
213+ js-sources: jsbits/clock.js
213214 hs-source-dirs: test
214215 ghc-options: -O0 -Wall -threaded -with-rtsopts=-N -fno-ignore-asserts
215216 if flag(dev)
@@ -287,6 +288,7 @@ test-suite test
287288test-suite properties
288289 type: exitcode-stdio-1.0
289290 main-is: Prop.hs
291+ js-sources: jsbits/clock.js
290292 hs-source-dirs: test
291293 ghc-options: -fno-ignore-asserts -Wall -O0 -threaded -with-rtsopts=-N
292294 if flag(dev)
@@ -316,6 +318,7 @@ test-suite maxrate
316318 type: exitcode-stdio-1.0
317319 default-language: Haskell2010
318320 main-is: MaxRate.hs
321+ js-sources: jsbits/clock.js
319322 hs-source-dirs: test
320323 ghc-options: -fno-ignore-asserts -O2 -Wall -threaded -with-rtsopts=-N
321324 if flag(dev)
@@ -596,7 +599,7 @@ executable chart
596599 default-language: Haskell2010
597600 hs-source-dirs: benchmark
598601 main-is: Chart.hs
599− if flag(dev)
602+ if flag(dev) && !impl(ghcjs)
600603 buildable: True
601604 build-Depends:
602605 base >= 4.8 && < 5
@@ -614,7 +617,7 @@ executable SearchQuery
614617 default-language: Haskell2010
615618 main-is: SearchQuery.hs
616619 hs-source-dirs: examples
617− if flag(examples) || flag(examples-sdl)
620+ if (flag(examples) || flag(examples-sdl)) && !impl(ghcjs)
618621 buildable: True
619622 build-Depends:
620623 streamly
test/MaxRate.hs+36−7
@@ -1,3 +1,4 @@
1+{-# LANGUAGE CPP #-}
12{-# LANGUAGE FlexibleContexts #-}
23
34import Streamly
@@ -81,37 +82,65 @@ main = hspec $ do
8182 -- will be effectively shorter. This becomes significant when the rates are
8283 -- lower (1 or lower). For rate 1 we lose 1 second in the end and for rate
8384 -- 10 0.1 second.
84− let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
85+ let rates = [1, 10, 100, 1000, 10000
86+#ifndef __GHCJS__
87+ , 100000, 1000000
88+#endif
89+ ]
8590 in describe "asyncly no consumer delay no producer delay" $
8691 forM_ rates (\r -> measureRate "asyncly" asyncly r 0 0 range)
8792
8893 -- XXX try staggering the dispatches to achieve higher rates
89− let rates = [1, 10, 100, 1000, 10000, 25000]
94+ let rates = [1, 10, 100, 1000
95+#ifndef __GHCJS__
96+ , 10000, 25000
97+#endif
98+ ]
9099 in describe "asyncly no consumer delay and 1 sec producer delay" $
91100 forM_ rates (\r -> measureRate "asyncly" asyncly r 0 1 range)
92101
93102 -- At lower rates (1/10) this is likely to vary quite a bit depending on
94103 -- the spread of random producer latencies generated.
95− let rates = [1, 10, 100, 1000, 10000, 25000]
104+ let rates = [1, 10, 100, 1000
105+#ifndef __GHCJS__
106+ , 10000, 25000
107+#endif
108+ ]
96109 in describe "asyncly no consumer delay and variable producer delay" $
97110 forM_ rates $ \r ->
98111 measureRate' "asyncly" asyncly r 0 (0.1, 3) range
99112
100− let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
113+ let rates = [1, 10, 100, 1000, 10000
114+#ifndef __GHCJS__
115+ , 100000, 1000000
116+#endif
117+ ]
101118 in describe "wAsyncly no consumer delay no producer delay" $
102119 forM_ rates (\r -> measureRate "wAsyncly" wAsyncly r 0 0 range)
103120
104− let rates = [1, 10, 100, 1000, 10000, 25000]
121+ let rates = [1, 10, 100, 1000
122+#ifndef __GHCJS__
123+ , 10000, 25000
124+#endif
125+ ]
105126 in describe "wAsyncly no consumer delay and 1 sec producer delay" $
106127 forM_ rates (\r -> measureRate "wAsyncly" wAsyncly r 0 1 range)
107128
108− let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
129+ let rates = [1, 10, 100, 1000, 10000
130+#ifndef __GHCJS__
131+ , 100000, 1000000
132+#endif
133+ ]
109134 in describe "aheadly no consumer delay no producer delay" $
110135 forM_ rates (\r -> measureRate "aheadly" aheadly r 0 0 range)
111136
112137 -- XXX after the change to stop workers when the heap is clearing
113138 -- thi does not work well at a 25000 ops per second, need to fix.
114− let rates = [1, 10, 100, 1000, 10000, 12500]
139+ let rates = [1, 10, 100, 1000
140+#ifndef __GHCJS__
141+ , 10000, 12500
142+#endif
143+ ]
115144 in describe "aheadly no consumer delay and 1 sec producer delay" $
116145 forM_ rates (\r -> measureRate "aheadly" aheadly r 0 1 range)
117146