@@ -6,14 +6,14 @@ import ProjectM36.DateExamples
6import ProjectM36.Error
6import ProjectM36.Error
7import qualified ProjectM36.Attribute as A
7import qualified ProjectM36.Attribute as A
8import qualified Data.Text as T
8import qualified Data.Text as T
9−import ProjectM36.Relation.Show.CSV
9+--import ProjectM36.Relation.Show.CSV
10import ProjectM36.Relation.Show.HTML
10import ProjectM36.Relation.Show.HTML
11import TutorialD.Interpreter.DatabaseContextExpr (interpretDatabaseContextExpr)
11import TutorialD.Interpreter.DatabaseContextExpr (interpretDatabaseContextExpr)
12import ProjectM36.RelationalExpression
12import ProjectM36.RelationalExpression
13−import qualified Data.HashSet as HS
13+--import qualified Data.HashSet as HS
14−import qualified Data.ByteString.Lazy.Char8 as BS
14+--import qualified Data.ByteString.Lazy.Char8 as BS
15−import qualified Data.IntMap as IM
15+--import qualified Data.IntMap as IM
16−import qualified Data.Hashable as Hash
16+--import qualified Data.Hashable as Hash
17import qualified Data.Vector as V
17import qualified Data.Vector as V
18import Options.Applicative
18import Options.Applicative
19import qualified Data.Map as M
19import qualified Data.Map as M
@@ -24,10 +24,12 @@ import Control.DeepSeq
24import Data.Text hiding (map)
24import Data.Text hiding (map)
25import Data.Monoid
25import Data.Monoid
27dumpcsv :: Relation -> IO ()
28dumpcsv :: Relation -> IO ()
28dumpcsv rel = case relationAsCSV rel of
29dumpcsv rel = case relationAsCSV rel of
29 Left err -> hPrint stderr err
30 Left err -> hPrint stderr err
30 Right bsData -> BS.putStrLn bsData
31 Right bsData -> BS.putStrLn bsData
32data BigrelArgs = BigrelArgs Int Int Text
34data BigrelArgs = BigrelArgs Int Int Text
@@ -67,14 +69,16 @@ matrixRun (BigrelArgs attributeCount tupleCount tutd) =
67 Right context' -> TIO.putStrLn $ relationAsHTML (relationVariables context' M.! "x")
69 Right context' -> TIO.putStrLn $ relationAsHTML (relationVariables context' M.! "x")
68 Left err -> hPrint stderr err
70 Left err -> hPrint stderr err
71intmapMatrixRun :: IO ()
73intmapMatrixRun :: IO ()
72intmapMatrixRun = do
74intmapMatrixRun = do
73 let matrix = intmapMatrixRelation 100 100000
75 let matrix = intmapMatrixRelation 100 100000
74 print matrix
76 print matrix
76--compare IntMap speed and size
79--compare IntMap speed and size
77--this is about 3 times faster (9 minutes) for 10x100000 and uses 800 MB
80--this is about 3 times faster (9 minutes) for 10x100000 and uses 800 MB
78intmapMatrixRelation :: Int -> Int -> HS.HashSet (IM.IntMap Atom)
82intmapMatrixRelation :: Int -> Int -> HS.HashSet (IM.IntMap Atom)
79intmapMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tupleCount]
83intmapMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tupleCount]
@@ -82,14 +86,18 @@ intmapMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tu
83instance Hash.Hashable (IM.IntMap Atom) where
87instance Hash.Hashable (IM.IntMap Atom) where
84 hashWithSalt salt tupMap = Hash.hashWithSalt salt (show tupMap)
88 hashWithSalt salt tupMap = Hash.hashWithSalt salt (show tupMap)
86vectorMatrixRun :: IO ()
92vectorMatrixRun :: IO ()
87vectorMatrixRun = do
93vectorMatrixRun = do
88 let matrix = vectorMatrixRelation 100 100000
94 let matrix = vectorMatrixRelation 100 100000
89 print matrix
95 print matrix
91-- 20 s 90 MBs- a clear win- ideal size is 10 * 100000 * 8 bytes = 80 MB! without IntAtom wrapper
98-- 20 s 90 MBs- a clear win- ideal size is 10 * 100000 * 8 bytes = 80 MB! without IntAtom wrapper
92--with IntAtom wrapper: 1m12s 90 MB
99--with IntAtom wrapper: 1m12s 90 MB
93vectorMatrixRelation :: Int -> Int -> HS.HashSet (V.Vector Atom)
101vectorMatrixRelation :: Int -> Int -> HS.HashSet (V.Vector Atom)
94vectorMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tupleCount]
102vectorMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tupleCount]
@@ -97,7 +105,7 @@ vectorMatrixRelation attributeCount tupleCount = HS.fromList $ map mapper [0..tu
98instance Hash.Hashable (V.Vector Atom) where
106instance Hash.Hashable (V.Vector Atom) where
99 hashWithSalt salt vec = Hash.hashWithSalt salt (show vec)
107 hashWithSalt salt vec = Hash.hashWithSalt salt (show vec)
101-- returns a relation with tupleCount tuples with a set of integer attributes attributesCount long
109-- returns a relation with tupleCount tuples with a set of integer attributes attributesCount long
102-- this is useful for performance and resource usage testing
110-- this is useful for performance and resource usage testing
103matrixRelation :: Int -> Int -> Either RelationalError Relation
111matrixRelation :: Int -> Int -> Either RelationalError Relation