-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef50645
commit 7a58a31
Showing
3 changed files
with
102 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE TypeFamilies #-} | ||
|
||
import Control.DeepSeq ( NFData, rnf ) | ||
import Control.Exception ( evaluate ) | ||
import Criterion.Main ( bench, nf, defaultMain ) | ||
|
||
import Data.Frame ( Column, Frameable, Indexable, Row, Frame ) | ||
import qualified Data.Frame as Frame | ||
import qualified Data.Vector as Vector | ||
|
||
import GHC.Generics ( Generic ) | ||
|
||
|
||
data Bench t | ||
= MkBench { field1 :: Column t Int | ||
, field2 :: Column t Int | ||
, field3 :: Column t Int | ||
, field4 :: Column t Int | ||
, field5 :: Column t Int | ||
, field6 :: Column t Int | ||
} | ||
deriving (Generic, Frameable) | ||
|
||
instance NFData (Row Bench) | ||
instance NFData (Frame Bench) | ||
|
||
instance Indexable Bench where | ||
type Key Bench = Int | ||
|
||
index = field1 | ||
|
||
|
||
main :: IO () | ||
main = do | ||
let rs = Vector.fromList [MkBench ix 0 0 0 0 0 | ix <- [0::Int .. 100_000]] | ||
fr = Frame.fromRows rs | ||
evaluate $ rnf rs | ||
evaluate $ rnf fr | ||
defaultMain | ||
[ bench "fromRows" $ nf (Frame.fromRows) rs | ||
, bench "toRows" $ nf (Frame.toRows) fr | ||
, bench "lookup" $ nf (Frame.lookup 100) fr | ||
, bench "at" $ nf (Frame.at (100, field5)) fr | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters