View Source cure_profiler (cure v0.1.0)
Cure Runtime Profiler
Collects runtime execution statistics to guide compiler optimizations. Provides lightweight instrumentation and aggregation of:
- Function call counts and frequencies
 - Hot path detection through call sequences
 - Type usage patterns at runtime
 - Memory allocation patterns
 - Performance metrics
 
Usage
% Initialize profiling
cure_profiler:start_profiling(),
% Run your code
my_application:run(),
% Collect profile data
ProfileData = cure_profiler:get_profile_data(),
% Use for optimization
OptimizedAST = cure_type_optimizer:optimize_with_profile(AST, ProfileData),
% Stop profiling
cure_profiler:stop_profiling().Profile Data Format
Profile data is stored as a map with the following structure:
#{
    function_calls => #{FunctionName => CallCount},
    call_sequences => [{Caller, Callee, Count}],
    type_usage => #{Type => UsageCount},
    memory_allocations => #{Function => AllocationSize},
    hot_functions => [FunctionName],
    hot_paths => [[FunctionName]],
    timestamp => Milliseconds
}
    Summary
Functions
-spec analyze_profile() -> map().
-spec export_profile(file:filename()) -> ok | {error, term()}.
-spec get_function_stats() -> map().
-spec get_hot_functions() -> [atom()].
-spec get_hot_functions(pos_integer()) -> [atom()].
-spec get_hot_paths() -> [[atom()]].
-spec get_profile_data() -> map().
-spec get_type_usage() -> map().
-spec import_profile(file:filename()) -> ok | {error, term()}.
-spec record_function_call(atom()) -> ok.
-spec record_function_call(atom(), pos_integer()) -> ok.
-spec record_memory_allocation(atom(), non_neg_integer()) -> ok.
-spec reset_profiling() -> ok.
      -spec start_profiling() -> ok.
      -spec start_profiling(map()) -> ok.
-spec stop_profiling() -> ok.