PreviousUpNext

15.4.523  src/lib/compiler/debugging-and-profiling/profiling/profiling-control-g.pkg

# profiling-control-g.pkg
#
# User interface for controling profiling.
# At present this primarily means counting calls to functions
# and measuring time spent in functions.
#
#
# See also:
#
#     src/lib/std/src/nj/runtime-profiling-control.pkg 

# Compiled by:
#     src/lib/compiler/debugging-and-profiling/debugprof.sublib

stipulate
    package ri  =  runtime_internals;                                                   # runtime_internals                             is from   src/lib/std/src/nj/runtime-internals.pkg
    package wpr =  write_time_profiling_report;                                         # write_time_profiling_report                   is from   src/lib/compiler/debugging-and-profiling/profiling/write-time-profiling-report.pkg
    package rpc =  ri::rpc;                                                             # "rpc" == "runtime_profiling_control".
                                                                                        # runtime_profiling_control                     is from   src/lib/std/src/nj/runtime-profiling-control.pkg
herein

    # This generic is invoked (only) in:
    #
    #     src/lib/compiler/toplevel/compiler/mythryl-compiler-g.pkg
    #
    generic package profiling_control_g   (
        #           ===================
        #                                                                               # profiling_dictionary_g                        is from   src/lib/compiler/debugging-and-profiling/profiling/profiling-dictionary-g.pkg
        package pd:  Profiling_Dictionary;                                              # Profiling_Dictionary                          is from   src/lib/compiler/debugging-and-profiling/profiling/profiling-dictionary.api
                                                                                        # "pd" == "profiling_dictionary".
        pervasive_fun_etc_defs_jar
          :
          { get_mapstack_set:   Void -> pd::Dictionary,
            set_mapstack_set:   pd::Dictionary -> Void
          };
    )
    : (weak)    Profiling_Control                                                       # Profiling_Control                             is from   src/lib/compiler/debugging-and-profiling/profiling/profiling-control.api
    {

        write_per_fun_time_profile_report        =  wpr::write_per_fun_time_profile_report;
        write_per_fun_time_profile_report0       =  wpr::write_per_fun_time_profile_report0;

        get_per_fun_timing_stats_sorted_by_cpu_time_then_callcount
            =
            wpr::get_per_fun_timing_stats_sorted_by_cpu_time_then_callcount;


        stipulate
            pervasive_done = REF FALSE;
        herein
            fun maybe_do_pervasive ()
                =
                if (not *pervasive_done)
                    #
                    pervasive_done := TRUE;

                    control_print::say   "Creating profiled version of standard library\n";

                    pd::replace  pervasive_fun_etc_defs_jar;
                fi;
        end;


        # Get/set the on/off switch for add_per_fun_call_counters_to_deep_syntax  # add_per_fun_call_counters_to_deep_syntax    is from   src/lib/compiler/debugging-and-profiling/profiling/add-per-fun-call-counters-to-deep-syntax.pkg

        fun set_compiler_to_add_per_fun_call_counters_to_deep_syntax ()
            =
            {   maybe_do_pervasive ();
                #
                ri::rpc::add_per_fun_call_counters_to_deep_syntax
                    :=
                    TRUE;
            };

        fun set_compiler_to_not_add_per_fun_call_counters_to_deep_syntax ()
            =
            ri::rpc::add_per_fun_call_counters_to_deep_syntax
                :=
                FALSE;


        fun compiler_is_set_to_add_per_fun_call_counters_to_deep_syntax ()
            =
            *ri::rpc::add_per_fun_call_counters_to_deep_syntax;


        start_sigvtalrm_time_profiler      =  rpc::start_sigvtalrm_time_profiler;
         stop_sigvtalrm_time_profiler      =   rpc::stop_sigvtalrm_time_profiler;
        sigvtalrm_time_profiler_is_running =  rpc::sigvtalrm_time_profiler_is_running;                  # Which of the above two was most recently called?


        zero_profiling_counts =  rpc::zero_profiling_counts;
    };
end;

# COPYRIGHT (c) 1995 AT&T Bell Laboratories.
## Subsequent changes by Jeff Prothero Copyright (c) 2010-2015,
## released per terms of SMLNJ-COPYRIGHT.


Comments and suggestions to: bugs@mythryl.org

PreviousUpNext