Add GHCJS support

This commit is contained in:
Harendra Kumar 2019-01-10 05:36:23 +05:30
parent cbff63f1cc
commit c86b6734f5
5 changed files with 65 additions and 9 deletions

View File

@ -1,3 +1,9 @@
## Unreleased
### Enhancements
* Add GHCJS support
## 0.6.0
### Breaking changes

12
cabal.project.ghcjs Normal file
View File

@ -0,0 +1,12 @@
compiler: ghcjs
packages: streamly.cabal
source-repository-package
type: git
location: https://github.com/ghcjs/ghcjs-base
tag: b8d51f65ae1921b2f031710bf75e17f216de442a
source-repository-package
type: git
location: https://github.com/harendra-kumar/hs-gauge
tag: 603dcf8c48f35e8a1ab3fc9838fbcde391bc842b

6
jsbits/clock.js Normal file
View File

@ -0,0 +1,6 @@
/* Hack! Supporting code for "clock" package
* "hspec" depends on clock.
*/
function h$hs_clock_darwin_gettime(when, p_d, p_o) {
h$clock_gettime(when, p_d, p_o);
}

View File

@ -210,6 +210,7 @@ library
test-suite test
type: exitcode-stdio-1.0
main-is: Main.hs
js-sources: jsbits/clock.js
hs-source-dirs: test
ghc-options: -O0 -Wall -threaded -with-rtsopts=-N -fno-ignore-asserts
if flag(dev)
@ -287,6 +288,7 @@ test-suite test
test-suite properties
type: exitcode-stdio-1.0
main-is: Prop.hs
js-sources: jsbits/clock.js
hs-source-dirs: test
ghc-options: -fno-ignore-asserts -Wall -O0 -threaded -with-rtsopts=-N
if flag(dev)
@ -316,6 +318,7 @@ test-suite maxrate
type: exitcode-stdio-1.0
default-language: Haskell2010
main-is: MaxRate.hs
js-sources: jsbits/clock.js
hs-source-dirs: test
ghc-options: -fno-ignore-asserts -O2 -Wall -threaded -with-rtsopts=-N
if flag(dev)
@ -596,7 +599,7 @@ executable chart
default-language: Haskell2010
hs-source-dirs: benchmark
main-is: Chart.hs
if flag(dev)
if flag(dev) && !impl(ghcjs)
buildable: True
build-Depends:
base >= 4.8 && < 5
@ -614,7 +617,7 @@ executable SearchQuery
default-language: Haskell2010
main-is: SearchQuery.hs
hs-source-dirs: examples
if flag(examples) || flag(examples-sdl)
if (flag(examples) || flag(examples-sdl)) && !impl(ghcjs)
buildable: True
build-Depends:
streamly

View File

@ -1,3 +1,4 @@
{-# LANGUAGE CPP #-}
{-# LANGUAGE FlexibleContexts #-}
import Streamly
@ -81,37 +82,65 @@ main = hspec $ do
-- will be effectively shorter. This becomes significant when the rates are
-- lower (1 or lower). For rate 1 we lose 1 second in the end and for rate
-- 10 0.1 second.
let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
let rates = [1, 10, 100, 1000, 10000
#ifndef __GHCJS__
, 100000, 1000000
#endif
]
in describe "asyncly no consumer delay no producer delay" $
forM_ rates (\r -> measureRate "asyncly" asyncly r 0 0 range)
-- XXX try staggering the dispatches to achieve higher rates
let rates = [1, 10, 100, 1000, 10000, 25000]
let rates = [1, 10, 100, 1000
#ifndef __GHCJS__
, 10000, 25000
#endif
]
in describe "asyncly no consumer delay and 1 sec producer delay" $
forM_ rates (\r -> measureRate "asyncly" asyncly r 0 1 range)
-- At lower rates (1/10) this is likely to vary quite a bit depending on
-- the spread of random producer latencies generated.
let rates = [1, 10, 100, 1000, 10000, 25000]
let rates = [1, 10, 100, 1000
#ifndef __GHCJS__
, 10000, 25000
#endif
]
in describe "asyncly no consumer delay and variable producer delay" $
forM_ rates $ \r ->
measureRate' "asyncly" asyncly r 0 (0.1, 3) range
let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
let rates = [1, 10, 100, 1000, 10000
#ifndef __GHCJS__
, 100000, 1000000
#endif
]
in describe "wAsyncly no consumer delay no producer delay" $
forM_ rates (\r -> measureRate "wAsyncly" wAsyncly r 0 0 range)
let rates = [1, 10, 100, 1000, 10000, 25000]
let rates = [1, 10, 100, 1000
#ifndef __GHCJS__
, 10000, 25000
#endif
]
in describe "wAsyncly no consumer delay and 1 sec producer delay" $
forM_ rates (\r -> measureRate "wAsyncly" wAsyncly r 0 1 range)
let rates = [1, 10, 100, 1000, 10000, 100000, 1000000]
let rates = [1, 10, 100, 1000, 10000
#ifndef __GHCJS__
, 100000, 1000000
#endif
]
in describe "aheadly no consumer delay no producer delay" $
forM_ rates (\r -> measureRate "aheadly" aheadly r 0 0 range)
-- XXX after the change to stop workers when the heap is clearing
-- thi does not work well at a 25000 ops per second, need to fix.
let rates = [1, 10, 100, 1000, 10000, 12500]
let rates = [1, 10, 100, 1000
#ifndef __GHCJS__
, 10000, 12500
#endif
]
in describe "aheadly no consumer delay and 1 sec producer delay" $
forM_ rates (\r -> measureRate "aheadly" aheadly r 0 1 range)