diff options
| author | aarne <aarne@cs.chalmers.se> | 2008-05-21 09:26:44 +0000 |
|---|---|---|
| committer | aarne <aarne@cs.chalmers.se> | 2008-05-21 09:26:44 +0000 |
| commit | 055c0d0d5a5bb0dc75904fe53df7f2e4f5732a8f (patch) | |
| tree | 0e63fb68c69c8f6ad0f78893c63420f0a3600e1c /src-3.0/GF/UseGrammar/Statistics.hs | |
| parent | 915a1de71783ab8446b1af9e72c7ba7dfbc12d3f (diff) | |
GF/src is now for 2.9, and the new sources are in src-3.0 - keep it this way until the release of GF 3
Diffstat (limited to 'src-3.0/GF/UseGrammar/Statistics.hs')
| -rw-r--r-- | src-3.0/GF/UseGrammar/Statistics.hs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src-3.0/GF/UseGrammar/Statistics.hs b/src-3.0/GF/UseGrammar/Statistics.hs new file mode 100644 index 000000000..46e4fcc3b --- /dev/null +++ b/src-3.0/GF/UseGrammar/Statistics.hs @@ -0,0 +1,44 @@ +---------------------------------------------------------------------- +-- | +-- Module : Statistics +-- Maintainer : AR +-- Stability : (stable) +-- Portability : (portable) +-- +-- > CVS $Date: 2005/09/04 11:45:38 $ +-- > CVS $Author: aarne $ +-- > CVS $Revision: 1.1 $ +-- +-- statistics on canonical grammar: amounts of generated code +-- AR 4\/9\/2005. +-- uses canonical grammar +----------------------------------------------------------------------------- + +module GF.UseGrammar.Statistics (prStatistics) where + +import GF.Infra.Modules +import GF.Infra.Option +import GF.Grammar.PrGrammar +import GF.Canon.GFC +import GF.Canon.MkGFC + +import GF.Data.Operations + +import Data.List (sortBy) + +-- | the top level function +prStatistics :: CanonGrammar -> String +prStatistics can = unlines $ [ + show (length mods) ++ "\t\t modules", + show chars ++ "\t\t gfc size", + "", + "Top 40 definitions" + ] ++ + [show d ++ "\t\t " ++ f | (d,f) <- tops] + where + tops = take 40 $ reverse $ sortBy (\ (i,_) (j,_) -> compare i j) defs + defs = [(length (prt (info2def j)), name m j) | (m,j) <- infos] + infos = [(m,j) | (m,ModMod mo) <- mods, j <- tree2list (jments mo)] + name m (f,_) = prt m ++ "." ++ prt f + mods = modules can + chars = length $ prCanon can |
