[m-rev.] diff: hlds_statistics.m

Julien Fischer juliensf at csse.unimelb.edu.au
Fri Feb 5 16:48:32 AEDT 2010


On Thu, 4 Feb 2010, Zoltan Somogyi wrote:

> For post-commit review by anyone.
>
> Zoltan.
>
> Add a new option, --proc-size-statistics <filename>. When specified, the
> compiler will append statistics about the sizes of procedures to the named
> file.
>
> compiler/hlds_statistics.m:
> 	New module that does this.
>
> compiler/options.m:
> doc/user_guide.texi:
> 	Document the new option.
>
> compiler/mercury_compile_front_end.m:
> 	Invoke the code to gather and print statistics if the option is
> 	specified.

I guess it would also be useful to print out the statistics after other
stages (e.g. after all the transform_hlds passes), indeed I see you have
left scope for this.  (It can wait until there is an actual need for
such a facility though.)

>
> compiler/hlds_pred.m:
> 	Improve the style of some old code.

...

> +%-----------------------------------------------------------------------------%
> Index: compiler/mercury_compile_front_end.m
> ===================================================================
> RCS file: /home/mercury/mercury1/repository/mercury/compiler/mercury_compile_front_end.m,v
> retrieving revision 1.2
> diff -u -b -r1.2 mercury_compile_front_end.m
> --- compiler/mercury_compile_front_end.m	16 Oct 2009 06:53:01 -0000	1.2
> +++ compiler/mercury_compile_front_end.m	3 Feb 2010 23:05:39 -0000
> @@ -86,6 +86,7 @@
> :- import_module check_hlds.unique_modes.
> :- import_module check_hlds.unused_imports.
> :- import_module hlds.hlds_error_util.
> +:- import_module hlds.hlds_statistics.
> :- import_module libs.compiler_util.
> :- import_module libs.file_util.
> :- import_module libs.globals.

...

> @@ -901,6 +904,37 @@
>         SimpList = []
>     ).
>
> +:- pred maybe_proc_statistics(bool::in, bool::in, string::in,
> +    module_info::in, module_info::out,
> +    list(error_spec)::in, list(error_spec)::out, io::di, io::uo) is det.
> +
> +maybe_proc_statistics(Verbose, Stats, Msg, !HLDS, !Specs, !IO) :-
> +    module_info_get_globals(!.HLDS, Globals),
> +    maybe_write_out_errors(Verbose, Globals, !HLDS, !Specs, !IO),
> +
> +    globals.lookup_string_option(Globals, proc_size_statistics, StatsFileName),
> +    ( StatsFileName = "" ->
> +        % The user has not asked us to print these statistics.
> +        true
> +    ;
> +        io.open_append(StatsFileName, StatsFileNameResult, !IO),
> +        (
> +            StatsFileNameResult = ok(StatsFileStream),
> +            maybe_write_string(Verbose,
> +                "% Generating proc statistics...\n", !IO),

I would say "Gathering" rather than "Generating".

This looks fine otherwise.

Julien.
--------------------------------------------------------------------------
mercury-reviews mailing list
Post messages to:       mercury-reviews at csse.unimelb.edu.au
Administrative Queries: owner-mercury-reviews at csse.unimelb.edu.au
Subscriptions:          mercury-reviews-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the reviews mailing list