mirror of
https://github.com/composewell/streamly.git
synced 2024-09-11 11:37:22 +03:00
Array.Foreign -> Array.Unboxed in tests and benchmarks & intenals
Co-authored-by: Ranjeet <ranjeet@composewell.com>
This commit is contained in:
parent
08acfe2e59
commit
18a226b9f0
2
.github/workflows/regression-check.yml
vendored
2
.github/workflows/regression-check.yml
vendored
@ -19,7 +19,7 @@ jobs:
|
|||||||
env:
|
env:
|
||||||
CI_BENCHMARKS_WITH_CUTOFF: >-
|
CI_BENCHMARKS_WITH_CUTOFF: >-
|
||||||
Data.Array
|
Data.Array
|
||||||
Data.Array.Foreign
|
Data.Array.Unboxed
|
||||||
Data.Fold
|
Data.Fold
|
||||||
Data.Parser
|
Data.Parser
|
||||||
Data.Parser.ParserD
|
Data.Parser.ParserD
|
||||||
|
@ -114,7 +114,7 @@ o_n_heap_serial value =
|
|||||||
]
|
]
|
||||||
|
|
||||||
moduleName :: String
|
moduleName :: String
|
||||||
moduleName = "Data.Array.Foreign"
|
moduleName = "Data.Array.Unboxed"
|
||||||
|
|
||||||
defStreamSize :: Int
|
defStreamSize :: Int
|
||||||
defStreamSize = defaultStreamSize
|
defStreamSize = defaultStreamSize
|
@ -1,5 +1,5 @@
|
|||||||
-- |
|
-- |
|
||||||
-- Module : Streamly.Benchmark.Data.Array.Foreign.Mut
|
-- Module : Streamly.Benchmark.Data.Array.Unboxed.Mut
|
||||||
-- Copyright : (c) 2021 Composewell Technologies
|
-- Copyright : (c) 2021 Composewell Technologies
|
||||||
-- License : BSD-3-Clause
|
-- License : BSD-3-Clause
|
||||||
-- Maintainer : streamly@composewell.com
|
-- Maintainer : streamly@composewell.com
|
||||||
@ -264,7 +264,7 @@ o_1_space_serial_marray value ~(array, indices) =
|
|||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
|
|
||||||
moduleName :: String
|
moduleName :: String
|
||||||
moduleName = "Data.Array.Foreign.Mut"
|
moduleName = "Data.Array.Unboxed.Mut"
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = do
|
main = do
|
@ -76,9 +76,9 @@ rtsOpts exeName benchName0 = unwords [general, exeSpecific, benchSpecific]
|
|||||||
| "Data.Array" `isPrefixOf` benchName
|
| "Data.Array" `isPrefixOf` benchName
|
||||||
&& "/o-1-space.generation.show" `isSuffixOf` benchName = "-M32M"
|
&& "/o-1-space.generation.show" `isSuffixOf` benchName = "-M32M"
|
||||||
| "Data.Array/o-1-space.transformationX4.map" == benchName = "-M32M"
|
| "Data.Array/o-1-space.transformationX4.map" == benchName = "-M32M"
|
||||||
| "Data.Array.Foreign/o-1-space.elimination.foldable.foldl"
|
| "Data.Array.Unboxed/o-1-space.elimination.foldable.foldl"
|
||||||
`isPrefixOf` benchName = "-K8M"
|
`isPrefixOf` benchName = "-K8M"
|
||||||
| "Data.Array.Foreign/o-1-space.elimination.foldable.sum" == benchName =
|
| "Data.Array.Unboxed/o-1-space.elimination.foldable.sum" == benchName =
|
||||||
"-K8M"
|
"-K8M"
|
||||||
| "Unicode.Char/o-1-space." `isPrefixOf` benchName = "-M32M"
|
| "Unicode.Char/o-1-space." `isPrefixOf` benchName = "-M32M"
|
||||||
| otherwise = ""
|
| otherwise = ""
|
||||||
|
@ -512,10 +512,10 @@ benchmark Data.SmallArray
|
|||||||
else
|
else
|
||||||
buildable: True
|
buildable: True
|
||||||
|
|
||||||
benchmark Data.Array.Foreign
|
benchmark Data.Array.Unboxed
|
||||||
import: bench-options
|
import: bench-options
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: Streamly/Benchmark/Data/Array/Foreign.hs
|
main-is: Streamly/Benchmark/Data/Array/Unboxed.hs
|
||||||
if flag(bench-core)
|
if flag(bench-core)
|
||||||
buildable: False
|
buildable: False
|
||||||
else
|
else
|
||||||
@ -523,10 +523,10 @@ benchmark Data.Array.Foreign
|
|||||||
if flag(limit-build-mem)
|
if flag(limit-build-mem)
|
||||||
ghc-options: +RTS -M1500M -RTS
|
ghc-options: +RTS -M1500M -RTS
|
||||||
|
|
||||||
benchmark Data.Array.Foreign.Mut
|
benchmark Data.Array.Unboxed.Mut
|
||||||
import: bench-options
|
import: bench-options
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: Streamly/Benchmark/Data/Array/Foreign/Mut.hs
|
main-is: Streamly/Benchmark/Data/Array/Unboxed/Mut.hs
|
||||||
if flag(limit-build-mem)
|
if flag(limit-build-mem)
|
||||||
ghc-options: +RTS -M1500M -RTS
|
ghc-options: +RTS -M1500M -RTS
|
||||||
if flag(bench-core)
|
if flag(bench-core)
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
-- |
|
-- |
|
||||||
-- Module : Streamly.Internal.Data.Array.Foreign
|
-- Module : Streamly.Internal.Data.Array.Unboxed
|
||||||
-- Copyright : (c) 2019 Composewell Technologies
|
-- Copyright : (c) 2019 Composewell Technologies
|
||||||
--
|
--
|
||||||
-- License : BSD3
|
-- License : BSD3
|
||||||
|
4
hie.yaml
4
hie.yaml
@ -72,8 +72,8 @@ cradle:
|
|||||||
cabal:
|
cabal:
|
||||||
- path: "./test/Streamly/Test/Data/Array.hs"
|
- path: "./test/Streamly/Test/Data/Array.hs"
|
||||||
component: "test:Data.Array"
|
component: "test:Data.Array"
|
||||||
- path: "./test/Streamly/Test/Data/Array/Foreign.hs"
|
- path: "./test/Streamly/Test/Data/Array/Unboxed.hs"
|
||||||
component: "test:Data.Array.Foreign"
|
component: "test:Data.Array.Unboxed"
|
||||||
- path: "./test/Streamly/Test/Data/Array/Stream/Foreign.hs"
|
- path: "./test/Streamly/Test/Data/Array/Stream/Foreign.hs"
|
||||||
component: "test:Data.Array.Stream.Foreign"
|
component: "test:Data.Array.Stream.Foreign"
|
||||||
- path: "./test/Streamly/Test/Data/Fold.hs"
|
- path: "./test/Streamly/Test/Data/Fold.hs"
|
||||||
|
@ -55,9 +55,9 @@ extra-source-files:
|
|||||||
benchmark/Streamly/Benchmark/Data/Array/Common.hs
|
benchmark/Streamly/Benchmark/Data/Array/Common.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Array/CommonImports.hs
|
benchmark/Streamly/Benchmark/Data/Array/CommonImports.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Array/SmallArray.hs
|
benchmark/Streamly/Benchmark/Data/Array/SmallArray.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Array/Foreign.hs
|
benchmark/Streamly/Benchmark/Data/Array/Unboxed.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Ring/Unboxed.hs
|
benchmark/Streamly/Benchmark/Data/Ring/Unboxed.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Array/Foreign/Mut.hs
|
benchmark/Streamly/Benchmark/Data/Array/Unboxed/Mut.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs
|
benchmark/Streamly/Benchmark/Data/Array/Stream/Foreign.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Fold/Window.hs
|
benchmark/Streamly/Benchmark/Data/Fold/Window.hs
|
||||||
benchmark/Streamly/Benchmark/Data/Parser/*.hs
|
benchmark/Streamly/Benchmark/Data/Parser/*.hs
|
||||||
@ -91,7 +91,7 @@ extra-source-files:
|
|||||||
test/Streamly/Test/Data/*.hs
|
test/Streamly/Test/Data/*.hs
|
||||||
test/Streamly/Test/Data/Array/CommonImports.hs
|
test/Streamly/Test/Data/Array/CommonImports.hs
|
||||||
test/Streamly/Test/Data/Array/Common.hs
|
test/Streamly/Test/Data/Array/Common.hs
|
||||||
test/Streamly/Test/Data/Array/Foreign.hs
|
test/Streamly/Test/Data/Array/Unboxed.hs
|
||||||
test/Streamly/Test/Data/Ring/Unboxed.hs
|
test/Streamly/Test/Data/Ring/Unboxed.hs
|
||||||
test/Streamly/Test/Data/Array/Stream/Foreign.hs
|
test/Streamly/Test/Data/Array/Stream/Foreign.hs
|
||||||
test/Streamly/Test/Data/Parser/ParserD.hs
|
test/Streamly/Test/Data/Parser/ParserD.hs
|
||||||
|
@ -94,13 +94,13 @@ targets =
|
|||||||
, "array_cmp"
|
, "array_cmp"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
, ("Data.Array.Foreign",
|
, ("Data.Array.Unboxed",
|
||||||
[ "array_grp"
|
[ "array_grp"
|
||||||
, "array_cmp"
|
, "array_cmp"
|
||||||
, "pinned_array_cmp"
|
, "pinned_array_cmp"
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
, ("Data.Array.Foreign.Mut",
|
, ("Data.Array.Unboxed.Mut",
|
||||||
[ "array_grp"
|
[ "array_grp"
|
||||||
, "array_cmp"
|
, "array_cmp"
|
||||||
, "noTest"
|
, "noTest"
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
-- |
|
-- |
|
||||||
-- Module : Streamly.Test.Data.Array.Foreign
|
-- Module : Streamly.Test.Data.Array.Unboxed
|
||||||
-- Copyright : (c) 2019 Composewell technologies
|
-- Copyright : (c) 2019 Composewell technologies
|
||||||
-- License : BSD-3-Clause
|
-- License : BSD-3-Clause
|
||||||
-- Maintainer : streamly@composewell.com
|
-- Maintainer : streamly@composewell.com
|
||||||
-- Stability : experimental
|
-- Stability : experimental
|
||||||
-- Portability : GHC
|
-- Portability : GHC
|
||||||
|
|
||||||
module Streamly.Test.Data.Array.Foreign (main) where
|
module Streamly.Test.Data.Array.Unboxed (main) where
|
||||||
|
|
||||||
#include "Streamly/Test/Data/Array/CommonImports.hs"
|
#include "Streamly/Test/Data/Array/CommonImports.hs"
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ import qualified Streamly.Internal.Data.Array.Stream.Foreign as AS
|
|||||||
type Array = A.Array
|
type Array = A.Array
|
||||||
|
|
||||||
moduleName :: String
|
moduleName :: String
|
||||||
moduleName = "Data.Array.Foreign"
|
moduleName = "Data.Array.Unboxed"
|
||||||
|
|
||||||
#include "Streamly/Test/Data/Array/Common.hs"
|
#include "Streamly/Test/Data/Array/Common.hs"
|
||||||
|
|
||||||
@ -43,7 +43,7 @@ testFromList =
|
|||||||
forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
|
forAll (vectorOf len (arbitrary :: Gen Int)) $ \list ->
|
||||||
monadicIO $ do
|
monadicIO $ do
|
||||||
let arr = A.fromList list
|
let arr = A.fromList list
|
||||||
xs <- run $ S.toList $ (S.unfold A.read) arr
|
xs <- run $ S.toList $ S.unfold A.read arr
|
||||||
assert (xs == list)
|
assert (xs == list)
|
||||||
|
|
||||||
testLengthFromStream :: Property
|
testLengthFromStream :: Property
|
||||||
@ -133,7 +133,7 @@ concatArrayW8 =
|
|||||||
|
|
||||||
unsafeSlice :: Int -> Int -> [Int] -> Bool
|
unsafeSlice :: Int -> Int -> [Int] -> Bool
|
||||||
unsafeSlice i n list =
|
unsafeSlice i n list =
|
||||||
let lst = take n $ drop i $ list
|
let lst = take n $ drop i list
|
||||||
arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
|
arr = A.toList $ A.getSliceUnsafe i n $ A.fromList list
|
||||||
in arr == lst
|
in arr == lst
|
||||||
|
|
||||||
@ -190,7 +190,7 @@ testByteLengthWithMA _ = do
|
|||||||
let arrW8 = MA.castUnsafe arrA :: MA.Array Word8
|
let arrW8 = MA.castUnsafe arrA :: MA.Array Word8
|
||||||
MA.byteLength arrA `shouldBe` MA.length arrW8
|
MA.byteLength arrA `shouldBe` MA.length arrW8
|
||||||
|
|
||||||
testBreakOn :: [Word8] -> Word8 -> [Word8] -> (Maybe [Word8]) -> IO ()
|
testBreakOn :: [Word8] -> Word8 -> [Word8] -> Maybe [Word8] -> IO ()
|
||||||
testBreakOn inp sep bef aft = do
|
testBreakOn inp sep bef aft = do
|
||||||
(bef_, aft_) <- A.breakOn sep (A.fromList inp)
|
(bef_, aft_) <- A.breakOn sep (A.fromList inp)
|
||||||
bef_ `shouldBe` A.fromList bef
|
bef_ `shouldBe` A.fromList bef
|
||||||
@ -207,7 +207,7 @@ testFromToList inp = A.toList (A.fromList inp) `shouldBe` inp
|
|||||||
testUnsafeIndxedFromList :: [Char] -> IO ()
|
testUnsafeIndxedFromList :: [Char] -> IO ()
|
||||||
testUnsafeIndxedFromList inp =
|
testUnsafeIndxedFromList inp =
|
||||||
let arr = A.fromList inp
|
let arr = A.fromList inp
|
||||||
in fmap (flip A.unsafeIndex arr) [0 .. (length inp - 1)] `shouldBe` inp
|
in fmap (`A.unsafeIndex` arr) [0 .. (length inp - 1)] `shouldBe` inp
|
||||||
|
|
||||||
testAsPtrUnsafeMA :: IO ()
|
testAsPtrUnsafeMA :: IO ()
|
||||||
testAsPtrUnsafeMA = do
|
testAsPtrUnsafeMA = do
|
||||||
@ -257,7 +257,7 @@ main =
|
|||||||
prop "fromList" testFromList
|
prop "fromList" testFromList
|
||||||
prop "foldMany with writeNUnsafe concats to original"
|
prop "foldMany with writeNUnsafe concats to original"
|
||||||
(foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
|
(foldManyWith (\n -> Fold.take n (A.writeNUnsafe n)))
|
||||||
prop "AS.concat . (A.fromList . (:[]) <$>) === id" $ concatArrayW8
|
prop "AS.concat . (A.fromList . (:[]) <$>) === id" concatArrayW8
|
||||||
describe "unsafeSlice" $ do
|
describe "unsafeSlice" $ do
|
||||||
it "partial" $ unsafeSlice 2 4 [1..10]
|
it "partial" $ unsafeSlice 2 4 [1..10]
|
||||||
it "none" $ unsafeSlice 10 0 [1..10]
|
it "none" $ unsafeSlice 10 0 [1..10]
|
||||||
@ -267,7 +267,7 @@ main =
|
|||||||
it "middle" (unsafeWriteIndex [1..10] 5 0 `shouldReturn` True)
|
it "middle" (unsafeWriteIndex [1..10] 5 0 `shouldReturn` True)
|
||||||
it "last" (unsafeWriteIndex [1..10] 9 0 `shouldReturn` True)
|
it "last" (unsafeWriteIndex [1..10] 9 0 `shouldReturn` True)
|
||||||
describe "Fold" $ do
|
describe "Fold" $ do
|
||||||
prop "writeLastN : 0 <= n <= len" $ testLastN
|
prop "writeLastN : 0 <= n <= len" testLastN
|
||||||
describe "writeLastN boundary conditions" $ do
|
describe "writeLastN boundary conditions" $ do
|
||||||
it "writeLastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
|
it "writeLastN -1" (testLastN_LN 10 (-1) `shouldReturn` True)
|
||||||
it "writeLastN 0" (testLastN_LN 10 0 `shouldReturn` True)
|
it "writeLastN 0" (testLastN_LN 10 0 `shouldReturn` True)
|
@ -223,11 +223,11 @@ test-suite Data.Array
|
|||||||
main-is: Streamly/Test/Data/Array.hs
|
main-is: Streamly/Test/Data/Array.hs
|
||||||
ghc-options: -main-is Streamly.Test.Data.Array.main
|
ghc-options: -main-is Streamly.Test.Data.Array.main
|
||||||
|
|
||||||
test-suite Data.Array.Foreign
|
test-suite Data.Array.Unboxed
|
||||||
import: test-options
|
import: test-options
|
||||||
type: exitcode-stdio-1.0
|
type: exitcode-stdio-1.0
|
||||||
main-is: Streamly/Test/Data/Array/Foreign.hs
|
main-is: Streamly/Test/Data/Array/Unboxed.hs
|
||||||
ghc-options: -main-is Streamly.Test.Data.Array.Foreign.main
|
ghc-options: -main-is Streamly.Test.Data.Array.Unboxed.main
|
||||||
|
|
||||||
test-suite Data.Ring.Unboxed
|
test-suite Data.Ring.Unboxed
|
||||||
import: test-options
|
import: test-options
|
||||||
|
@ -21,7 +21,7 @@ rtsOpts relaxMem exeName target =
|
|||||||
targetSpecific =
|
targetSpecific =
|
||||||
case target of
|
case target of
|
||||||
-- XXX Data.Array.* heap requirement increased for GHC-8.10
|
-- XXX Data.Array.* heap requirement increased for GHC-8.10
|
||||||
"Data.Array.Foreign" -> "-M128M"
|
"Data.Array.Unboxed" -> "-M128M"
|
||||||
"Prelude.Rate" -> "-M512M"
|
"Prelude.Rate" -> "-M512M"
|
||||||
-- For -O0 case writeChunks test fails, maybe we should have a
|
-- For -O0 case writeChunks test fails, maybe we should have a
|
||||||
-- separate flag for O0 case?
|
-- separate flag for O0 case?
|
||||||
|
Loading…
Reference in New Issue
Block a user