+\subsection{Statistics}
+%* *
+%*********************************************************
+
+\begin{code}
+getRnStats :: [RenamedHsDecl] -> RnMG Doc
+getRnStats all_decls
+ = getIfacesRn `thenRn` \ ifaces ->
+ let
+ Ifaces this_mod mod_vers_map export_envs decls_fm all_names imp_names unslurped_insts deferred_data_decls inst_mods = ifaces
+ n_mods = sizeFM mod_vers_map
+
+ decls_imported = filter is_imported_decl all_decls
+ decls_read = [decl | (name, (_, avail, decl)) <- fmToList decls_fm,
+ name == availName avail,
+ -- Data, newtype, and class decls are in the decls_fm
+ -- under multiple names; the tycon/class, and each
+ -- constructor/class op too.
+ not (isLocallyDefined name)
+ ]
+
+ (cd_rd, dd_rd, add_rd, nd_rd, and_rd, sd_rd, vd_rd, _) = count_decls decls_read
+ (cd_sp, dd_sp, add_sp, nd_sp, and_sp, sd_sp, vd_sp, id_sp) = count_decls decls_imported
+
+ inst_decls_unslurped = length (bagToList unslurped_insts)
+ inst_decls_read = id_sp + inst_decls_unslurped
+
+ stats = vcat
+ [int n_mods <> text " interfaces read",
+ hsep [int cd_sp, text "class decls imported, out of",
+ int cd_rd, text "read"],
+ hsep [int dd_sp, text "data decls imported (of which", int add_sp, text "abstractly), out of",
+ int dd_rd, text "read"],
+ hsep [int nd_sp, text "newtype decls imported (of which", int and_sp, text "abstractly), out of",
+ int nd_rd, text "read"],
+ hsep [int sd_sp, text "type synonym decls imported, out of",
+ int sd_rd, text "read"],
+ hsep [int vd_sp, text "value signatures imported, out of",
+ int vd_rd, text "read"],
+ hsep [int id_sp, text "instance decls imported, out of",
+ int inst_decls_read, text "read"]
+ ]
+ in
+ returnRn (hcat [text "Renamer stats: ", stats])
+
+is_imported_decl (DefD _) = False
+is_imported_decl (ValD _) = False
+is_imported_decl decl = not (isLocallyDefined (hsDeclName decl))
+
+count_decls decls
+ = -- pprTrace "count_decls" (ppr PprDebug decls
+ --
+ -- $$
+ -- text "========="
+ -- $$
+ -- ppr PprDebug imported_decls
+ -- ) $
+ (class_decls,
+ data_decls, abstract_data_decls,
+ newtype_decls, abstract_newtype_decls,
+ syn_decls,
+ val_decls,
+ inst_decls)
+ where
+ class_decls = length [() | ClD _ <- decls]
+ data_decls = length [() | TyD (TyData DataType _ _ _ _ _ _ _) <- decls]
+ newtype_decls = length [() | TyD (TyData NewType _ _ _ _ _ _ _) <- decls]
+ abstract_data_decls = length [() | TyD (TyData DataType _ _ _ [] _ _ _) <- decls]
+ abstract_newtype_decls = length [() | TyD (TyData NewType _ _ _ [] _ _ _) <- decls]
+ syn_decls = length [() | TyD (TySynonym _ _ _ _) <- decls]
+ val_decls = length [() | SigD _ <- decls]
+ inst_decls = length [() | InstD _ <- decls]
+
+\end{code}
+
+%*********************************************************
+%* *