Commit a05fdcd5 authored by Camil Staps's avatar Camil Staps
Browse files

Add CloogleDBStats

parent f8326bc3
...@@ -36,6 +36,19 @@ from TypeTree import :: TypeTree ...@@ -36,6 +36,19 @@ from TypeTree import :: TypeTree
, instance_map :: !Map Name [Index] //* Map class names to DeriveEntries , instance_map :: !Map Name [Index] //* Map class names to DeriveEntries
} }
:: CloogleDBStats =
{ n_modules :: Int
, n_functions :: Int
, n_functions_with_type :: Int
, n_unique_types :: Int
, type_tree_depth :: Int
, n_type_definitions :: Int
, n_classes :: Int
, n_instances :: Int
, n_derivations :: Int
, n_syntax_constructs :: Int
}
:: AnnotationKey :: AnnotationKey
= MatchingNGrams = MatchingNGrams
| UnifierSize | UnifierSize
...@@ -220,6 +233,8 @@ openDB :: !*File -> *(!Maybe *CloogleDB, !*File) ...@@ -220,6 +233,8 @@ openDB :: !*File -> *(!Maybe *CloogleDB, !*File)
resetDB :: !*CloogleDB -> *CloogleDB resetDB :: !*CloogleDB -> *CloogleDB
dbStats :: !*CloogleDB -> *(CloogleDBStats, *CloogleDB)
getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB) getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB)
getIndices :: ![Index] !*CloogleDB -> *([Entry CloogleEntry AnnotationKey Annotation], *CloogleDB) getIndices :: ![Index] !*CloogleDB -> *([Entry CloogleEntry AnnotationKey Annotation], *CloogleDB)
......
...@@ -296,6 +296,35 @@ where ...@@ -296,6 +296,35 @@ where
resetDB :: !*CloogleDB -> *CloogleDB resetDB :: !*CloogleDB -> *CloogleDB
resetDB wrap=:{db} = {wrap & db='DB'.resetDB db} resetDB wrap=:{db} = {wrap & db='DB'.resetDB db}
dbStats :: !*CloogleDB -> *(CloogleDBStats, *CloogleDB)
dbStats wrap=:{db,types}
# (es,db) = 'DB'.allEntries db
# stats = foldr count zero es
= (stats, {wrap & db=db})
where
count :: CloogleEntry CloogleDBStats -> CloogleDBStats
count (ModuleEntry _) st = {st & n_modules=st.n_modules+1}
count (FunctionEntry _) st = {st & n_functions=st.n_functions+1}
count (ClassEntry _) st = {st & n_classes=st.n_classes+1}
count (TypeDefEntry _) st = {st & n_type_definitions=st.n_type_definitions+1}
count (InstanceEntry _) st = {st & n_instances=st.n_instances+1}
count (DeriveEntry _) st = {st & n_derivations=st.n_derivations+1}
count (SyntaxEntry _) st = {st & n_syntax_constructs=st.n_syntax_constructs+1}
zero :: CloogleDBStats
zero =
{ n_modules = 0
, n_functions = 0
, n_functions_with_type = typeTreeNodes types
, n_unique_types = typeTreeSize types
, type_tree_depth = typeTreeDepth types
, n_type_definitions = 0
, n_classes = 0
, n_instances = 0
, n_derivations = 0
, n_syntax_constructs = 0
}
getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB) getIndex :: !Index !*CloogleDB -> *(Entry CloogleEntry AnnotationKey Annotation, *CloogleDB)
getIndex idx wrap=:{db} getIndex idx wrap=:{db}
# (e,db) = 'DB'.getIndex idx db # (e,db) = 'DB'.getIndex idx db
......
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