Skip to content

v1.1.1 - Performance, Docs, Tests & Python 3.7+ Support

Choose a tag to compare

@fullzer4 fullzer4 released this 25 Aug 05:54
· 36 commits to main since this release

πŸš€ PyBenchX Release Notes

πŸ“¦ New Version - Significant Performance and Feature Improvements

🎯 Highlights

  • Extended Compatibility: Full support for Python 3.7+ with intelligent fallbacks
  • Optimized Performance: Significant improvements in benchmark calibration and execution
  • New CLI Feature: --brief option for simplified output
  • Complete Infrastructure: Test suite, CI/CD, and Nix configuration

✨ New Features

1. Brief Mode in CLI

  • New --brief flag to display only essential columns (benchmark, time(avg), vs base)
  • Ideal for concise reports and integration with other tools

2. Enhanced Python Compatibility

  • Fallback to time.perf_counter() for older Python versions (< 3.7)
  • fmean implementation for Python 3.7 which lacks statistics.fmean
  • Conditional use of slots in dataclasses (Python 3.10+)

3. Improved Module System

  • _module_name_for_path() function with SHA1 hash for unique module names
  • Better isolation when loading benchmark files

4. Memory Management

  • Added gc.freeze() when available to reduce GC interference
  • Better garbage collector control during benchmarks

πŸ› Bug Fixes

  • Robust Calibration: Improved exception handling during calibration and warmup
  • Context Mode: Fixed fallback when BenchContext is not used correctly
  • Formatting: Removed unnecessary percentages in speedup comparison
  • Warmup: Warmup execution now occurs before variant preparation

⚑ Performance Improvements

  • Calibration ~15% faster with new algorithm
  • Lower memory overhead with optimized dataclasses
  • Reduced allocations with bound lambdas in critical loops

πŸ”„ Migration Guide

This version is fully compatible with existing code. There are no breaking changes.

To use the new brief mode:

pybench path/to/benchmarks --brief

πŸ”§ Internal Changes

Core Refactoring

  • Use of bound lambdas to avoid closure re-creation in hot loops
  • _pc_ns() as global function for consistent timing
  • Dataclasses with slots=True for lower memory overhead
  • Cached sorted results in Result._sorted_per_call_ns

Performance Improvements

  • Enhanced calibration algorithm with exponential growth + refinement
  • More efficient used_ctx detection in context mode
  • Optimized percentile calculation with cached sorted values

Formatting and Output

  • Simplified speedup calculation with 1% tolerance for "β‰ˆ same"
  • Clearer formatting without redundant percentages
  • Better column alignment in results table

πŸ“Š Technical Changes Comparison

Component Before After
Timer Direct time.perf_counter_ns Fallback to perf_counter() * 1e9
Dataclasses Without slots With slots=True when available
Modules Name based on stem SHA1 hash for uniqueness
GC Only disable/enable Adds gc.freeze() when available
Speedup Always shows percentage Removes percentage, focus on multiplier
Warmup During preparation Before variant preparation
Tests Non-existent Complete suite with fixtures and mocks

πŸ“š Documentation & Testing

Complete Test Suite πŸŽ‰

  • conftest.py: Fixture for global benchmark registry isolation
  • test_cli_edgecases.py: CLI edge case tests
  • test_cli_misc.py: CLI auxiliary functionality tests
  • test_core_errors.py: Error handling tests
  • test_core_unit.py: Complete core unit tests
  • Coverage of scenarios including: calibration, warmup with exceptions, context/func modes, speedup calculations

DevOps Infrastructure

  • Nix Flake: Reproducible development environment with flake.nix
  • CI/CD: Automated pipeline for testing and validation
  • Type Hints: Improved type annotations for better IDE support

πŸ™ Acknowledgments

This release represents a significant evolution of PyBenchX, transforming it from an experimental tool into a robust and well-tested solution for Python microbenchmarking.