Overview
Z3 provides detailed statistics about solver execution, including conflict counts, decision counts, memory usage, and theory-specific metrics. These statistics are essential for performance analysis, debugging, and optimization.Collecting Statistics
Basic Statistics Retrieval
Reading Statistics
Iterating Through All Statistics
Formatted Statistics Output
Key Statistics Categories
Core Solver Statistics
Memory Statistics
Resource Limits
Theory-Specific Statistics
SAT Solver Statistics
Arithmetic Theory Statistics
Array Theory Statistics
Performance Analysis
Identifying Bottlenecks
Comparing Solver Configurations
Global Memory Statistics
Estimated Allocation Size
Best Practices
When to Collect Statistics
Collect statistics to:- Profile solver performance on benchmarks
- Debug timeout or memory issues
- Compare different solving strategies
- Monitor production system health
- Identify theory-specific bottlenecks
Interpreting Statistics
- High conflict count: Problem is complex, consider preprocessing or simplification
- Low decision count: Problem is easy or well-structured
- High restart count: SAT solver is struggling, try different restart strategies
- Memory growth: Problem size is large, consider incremental solving or memory limits
- Long solving time with low conflicts: Theory solver may be slow, try different theory options
Statistical Logging
Common Statistics Keys
Universal Statistics
time- Total solving time in secondsmemory- Current memory usage in MBmax-memory- Peak memory usage in MBrlimit-count- Resource limit counternum-allocs- Number of allocations
SAT Statistics
conflicts- Number of conflictsdecisions- Number of decisionspropagations- Number of propagationsrestarts- Number of restartsmk-bool-var- Boolean variables created
Theory Statistics
arith-conflicts- Arithmetic conflictsarith-bound-propagations- Bound propagationsarray-axiom1- Array select-store axiomsbv-conflicts- Bit-vector conflicts
API Reference
Statistics Management
Z3_solver_get_statistics- Get statistics from solver (api_solver.cpp:789)Z3_stats_inc_ref- Increment reference counter (api_stats.cpp:39)Z3_stats_dec_ref- Decrement reference counter (api_stats.cpp:47)Z3_stats_to_string- Convert to string (api_stats.cpp:25)
Reading Statistics
Z3_stats_size- Get number of statistics (api_stats.cpp:56)Z3_stats_get_key- Get statistic key name (api_stats.cpp:64)Z3_stats_is_uint- Check if unsigned integer (api_stats.cpp:76)Z3_stats_is_double- Check if double (api_stats.cpp:88)Z3_stats_get_uint_value- Get unsigned value (api_stats.cpp:100)Z3_stats_get_double_value- Get double value (api_stats.cpp:116)
Global Statistics
Z3_get_estimated_alloc_size- Get global memory estimate (api_stats.cpp:132)
See Also
- Parameters - Configuring solver behavior
- Solver API - Using solvers
- Tactics - Optimization strategies with tactics
