Commit 97b708ab authored by Aggelos Giantsios's avatar Aggelos Giantsios

Set a type alias for the statistics

parent 36650a70
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
-- --
module Sequential(orbit) where module Sequential(orbit) where
import Table (Freq, VTable, Vertex, get_freq, freq_to_stat, is_member, insert, new, to_list) import Table (Freq, Stats, VTable, Vertex, get_freq, freq_to_stat, is_member, insert, new, to_list)
import Data.Hashable (hash) import Data.Hashable (hash)
import Data.Dequeue (BankersDequeue, fromList, popFront, pushBack) import Data.Dequeue (BankersDequeue, fromList, popFront, pushBack)
import OrbitUtils (now) import OrbitUtils (now)
...@@ -24,7 +24,7 @@ type Conf = ([Vertex -> Vertex], Int) ...@@ -24,7 +24,7 @@ type Conf = ([Vertex -> Vertex], Int)
-- where the hash table is of size TableSize. -- where the hash table is of size TableSize.
-- The function returns a pair consisting of the computed orbit and a singleton -- The function returns a pair consisting of the computed orbit and a singleton
-- list of statistics (mainly runtime and fill degree of the table). -- list of statistics (mainly runtime and fill degree of the table).
orbit :: [Vertex -> Vertex] -> [Vertex] -> Int -> ([Vertex], [[(String, String)]]) orbit :: [Vertex -> Vertex] -> [Vertex] -> Int -> ([Vertex], [Stats])
orbit gs xs tableSize = (orbit, [stat]) orbit gs xs tableSize = (orbit, [stat])
-- assemble static configuration -- assemble static configuration
where staticMachConf = mk_static_mach_conf gs tableSize where staticMachConf = mk_static_mach_conf gs tableSize
...@@ -91,7 +91,7 @@ get_table_size :: Conf -> Int ...@@ -91,7 +91,7 @@ get_table_size :: Conf -> Int
get_table_size staticMachConf = snd staticMachConf get_table_size staticMachConf = snd staticMachConf
-- produce readable statistics -- produce readable statistics
seq_stats :: Int -> Freq -> Int -> [(String, String)] seq_stats :: Int -> Freq -> Int -> Stats
seq_stats elapsedTime frequency vertsRecvd = seq_stats elapsedTime frequency vertsRecvd =
("wall_time", show elapsedTime) : ("vertices_recvd", show vertsRecvd) : freq_to_stat frequency ("wall_time", show elapsedTime) : ("vertices_recvd", show vertsRecvd) : freq_to_stat frequency
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
-- orbit-int hash table (storing vertices on a worker) -- orbit-int hash table (storing vertices on a worker)
-- --
module Table( Freq module Table( Freq
, Stats
, VTable , VTable
, Vertex , Vertex
, new , new
...@@ -26,6 +27,7 @@ import Data.Array (Array, elems, listArray, (!), (//)) ...@@ -26,6 +27,7 @@ import Data.Array (Array, elems, listArray, (!), (//))
type Freq = [Int] type Freq = [Int]
type Vertex = Int type Vertex = Int
type VTable = Array Int [Vertex] type VTable = Array Int [Vertex]
type Stats = [(String, String)]
-- Note: Hash tables have a fixed number of slots but each slot can store -- Note: Hash tables have a fixed number of slots but each slot can store
-- a list of vertices. The functions is_member/3 and insert/3 -- a list of vertices. The functions is_member/3 and insert/3
...@@ -101,7 +103,7 @@ sum_freqs fs = foldl (flip sum_freqs2) [] fs ...@@ -101,7 +103,7 @@ sum_freqs fs = foldl (flip sum_freqs2) [] fs
-- freq_to_stat produces a readable statistics from a table fill frequency; -- freq_to_stat produces a readable statistics from a table fill frequency;
-- the input frequency F is itself part of the statistics -- the input frequency F is itself part of the statistics
freq_to_stat :: Freq -> [(String, String)] freq_to_stat :: Freq -> Stats
freq_to_stat frequency = [ ("freq", show frequency) freq_to_stat frequency = [ ("freq", show frequency)
, ("size", show $ freq_to_vertices frequency) , ("size", show $ freq_to_vertices frequency)
, ("slots", show $ freq_to_slots frequency) , ("slots", show $ freq_to_slots frequency)
...@@ -116,7 +118,7 @@ freq_to_stat frequency = [ ("freq", show frequency) ...@@ -116,7 +118,7 @@ freq_to_stat frequency = [ ("freq", show frequency)
-- freq_from_stat extracts a table fill frequency from a statistics Stat -- freq_from_stat extracts a table fill frequency from a statistics Stat
-- (assuming Stat was produced by freq_to_stat/1, otherwise returns []); -- (assuming Stat was produced by freq_to_stat/1, otherwise returns []);
freq_from_stat :: [(String, String)] -> Freq freq_from_stat :: Stats -> Freq
freq_from_stat stat = freq_from_stat stat =
case "freq" `lookup` stat of case "freq" `lookup` stat of
Just val -> read val :: [Int] Just val -> read val :: [Int]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment