stat; type of imperatives in lib/resource

This commit is contained in:
aarne
2005-09-04 10:45:37 +00:00
parent 6a01681d73
commit 1a9a2ceaea
7 changed files with 65 additions and 10 deletions

View File

@@ -14,6 +14,12 @@ Changes in functionality since May 17, 2005, release of GF Version 2.2
<p>
4/9 (AR) Added the option <tt>pg -printer=stat</tt> to show
statistics of gfc compilation result. To be extended with new information.
The most important stats now are the top-40 sized definitions.
<p>
1/7 <b>Release of GF 2.3</b>.
<p>

View File

@@ -5,16 +5,16 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/05/30 21:08:14 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.15 $
-- > CVS $Revision: 1.16 $
--
-- (Description of the module)
-----------------------------------------------------------------------------
module GF.Canon.MkGFC (prCanonModInfo, prCanon, prCanonMGr,
canon2grammar, grammar2canon, -- buildCanonGrammar,
info2mod,
info2mod,info2def,
trExp, rtExp, rtQIdent) where
import GF.Canon.GFC

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/05/30 18:39:44 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.15 $
-- > CVS $Revision: 1.16 $
--
-- AR 7\/12\/1999 - 1\/4\/2000 - 10\/5\/2003
--
@@ -107,6 +107,7 @@ instance Print A.Case where prt = C.printTree
instance Print A.CType where prt = C.printTree
instance Print A.Label where prt = C.printTree
instance Print A.Module where prt = C.printTree
instance Print A.Def where prt = C.printTree
instance Print A.Canon where prt = C.printTree
instance Print A.Sort where prt = C.printTree

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/07/01 19:54:09 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.9 $
-- > CVS $Revision: 1.10 $
--
-- Help on shell commands. Generated from HelpFile by 'make help'.
-- PLEASE DON'T EDIT THIS FILE.
@@ -523,6 +523,7 @@ txtHelpFile =
"\n -printer=fullform full-form lexicon, short format" ++
"\n *-printer=xml XML: DTD for the pg command, object for st" ++
"\n -printer=old old GF: file readable by GF 1.2" ++
"\n -printer=stat show some statistics of generated GFC" ++
"\n" ++
"\n-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)" ++
"\n" ++

View File

@@ -5,9 +5,9 @@
-- Stability : (stable)
-- Portability : (portable)
--
-- > CVS $Date: 2005/09/01 09:53:19 $
-- > CVS $Author: peb $
-- > CVS $Revision: 1.69 $
-- > CVS $Date: 2005/09/04 11:45:38 $
-- > CVS $Author: aarne $
-- > CVS $Revision: 1.70 $
--
-- A database for customizable GF shell commands.
--
@@ -61,6 +61,7 @@ import GF.Speech.PrSLF (slfPrinter)
import GF.Data.Zipper
import GF.UseGrammar.Statistics
import GF.UseGrammar.Morphology
import GF.API.GrammarToHaskell
-----import GrammarToCanon (showCanon, showCanonOpt)
@@ -249,6 +250,7 @@ customGrammarPrinter =
,(strCI "opts", prOpts . stateOptions)
,(strCI "words", unwords . stateGrammarWords)
,(strCI "printnames", C.prPrintnamesGrammar . stateGrammarST)
,(strCI "stat", prStatistics . stateGrammarST)
{- ----
(strCI "gf", prt . st2grammar . stateGrammarST) -- DEFAULT
,(strCI "canon", showCanon "Lang" . stateGrammarST)

View File

@@ -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

View File

@@ -494,6 +494,7 @@ q, quit: q
-printer=fullform full-form lexicon, short format
*-printer=xml XML: DTD for the pg command, object for st
-printer=old old GF: file readable by GF 1.2
-printer=stat show some statistics of generated GFC
-startcat, like -cat, but used in grammars (to avoid clash with keyword cat)