Skip to main content

Module profiling

Module profiling 

Source
Expand description

§Profiling (Beta 2 Enhanced)

This module provides comprehensive utilities for profiling computational performance in scientific applications with advanced features for detailed performance analysis and optimization.

§Enhanced Features (Beta 2)

  • Function-level timing instrumentation
  • Memory allocation tracking
  • Hierarchical profiling for nested operations
  • Easy-to-use macros for profiling sections of code
  • Flame graph generation for visualizing call hierarchies
  • Automated bottleneck detection with performance thresholds
  • System-level resource monitoring (CPU, memory, network)
  • Hardware performance counter integration
  • Differential profiling to compare performance between runs
  • Continuous performance monitoring for long-running processes
  • Export capabilities to various formats (JSON, CSV, flamegraph)

§Usage

use scirs2_core::profiling::{Profiler, Timer, MemoryTracker};

// Start the global profiler
Profiler::global().lock().expect("Operation failed").start();

// Time a function call
let result = Timer::time_function("matrix_multiplication", || {
    // Perform matrix multiplication
    // ...
    42 // Return some result
});

// Time a code block with more control
let timer = Timer::start("data_processing");
// Perform data processing
// ...
timer.stop();

// Track memory allocations
let tracker = MemoryTracker::start("large_array_operation");
let large_array = vec![0; 1_000_000];
// ...
tracker.stop();

// Print profiling report
Profiler::global().lock().expect("Operation failed").print_report();

// Stop profiling
Profiler::global().lock().expect("Operation failed").stop();

Re-exports§

pub use entries::MemoryEntry;
pub use entries::TimingEntry;
pub use memory::profiling_memory_tracker;
pub use memory::MemoryTracker;
pub use profiler::Profiler;
pub use timer::Timer;
pub use advanced::BottleneckConfig;
pub use advanced::BottleneckDetector;
pub use advanced::BottleneckReport;
pub use advanced::BottleneckType;
pub use advanced::DifferentialProfiler;
pub use advanced::DifferentialReport;
pub use advanced::ExportableProfiler;
pub use advanced::FlameGraphGenerator;
pub use advanced::FlameGraphNode;
pub use advanced::MemoryDiff;
pub use advanced::PerformanceChange;
pub use advanced::PerformanceStats;
pub use advanced::ProfileSnapshot;
pub use advanced::ResourceStats;
pub use advanced::SystemResourceMonitor;
pub use advanced::TimingDiff;
pub use comprehensive::ComprehensiveConfig;
pub use comprehensive::ComprehensiveProfiler;
pub use comprehensive::ComprehensiveReport;

Modules§

adaptive
Adaptive Optimization System
advanced
Advanced profiling capabilities for Beta 2
comprehensive
Comprehensive profiling integration that combines application profiling with system monitoring
continuousmonitoring
Continuous monitoring functionality
coverage
Test Coverage Analysis System
dashboards
Performance Dashboards System
entries
Data structures for profiling entries (timing and memory)
flame_graph_svg
SVG Flame Graph Export
hardware_counters
Hardware Performance Counter Integration
memory
Memory allocation tracking functionality for profiling
performance_hints
Function-Level Performance Hinting System
production
Production Profiling System
profiler
Main profiler implementation for collecting performance metrics
system_monitor
System Resource Monitoring
timer
Timer functionality for profiling code execution time