Skip to content
  • Philip Chimento's avatar
    profiler: Reduce API surface · c3a4f694
    Philip Chimento authored
    We actually don't want callers to have control over the lifetime of the
    profiler object. It should be tied entirely to the GjsContext. This makes
    most of the profiler API private.
    
    Now, to control the profiler, you have two construct-only properties of
    GjsContext: profiler-enabled and profiler-sigusr2. profiler-sigusr2
    implies profiler-enabled, and does the work that
    gjs_profiler_setup_signals() would previously have accomplished. The
    GJS_PROFILER_ENABLED environment variable, if set, overrides the value of
    profiler-signal.
    
    By default when you call gjs_context_eval(), the profiler will be started
    and stopped automatically around the evaluation of the JS code. If you
    need to call gjs_context_eval() more than once, you probably only want to
    do that within one profiling session. For that case we provide the
    gjs_profiler_start() and gjs_profiler_stop() API, which will prevent the
    auto-starting and stopping.
    c3a4f694