Skip to content

ernieputnic/py-bitmod

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

py_bitmod

A micro-benchmarking tool for comparing integer parity checks in Python — including modulo division, bitwise AND, and their compiled C equivalents via ctypes, with support for both single-value and batch-mode testing.

Overview

py_bitmod is a minimal Python 3 project for benchmarking the runtime performance of various parity-checking methods:

  • Modulo method
  • Bitwise method
  • C bitwise method — compiled C function via ctypes
  • Batch bitwise method — Python loop over randomized input array
  • Batch C bitwise method — compiled C function via ctypes, optimized for batch processing

The CLI measures execution time using Python’s time.perf_counter().

Setup

Python environment

Create a virtual environment and install the package:

python3 -m venv venv
source venv/bin/activate  # or venv\Scripts\activate on Windows
pip install .

C Build & Install

make            # build shared and static libraries
make install    # install libbitmod.so for CLI usage
make test       # test run with default input
make rebuild    # clean and rebuild all artifacts
make clean      # remove build artifacts and installed library

Usage

CLI

# Show help message
py-bitmod -h

# Run with optional test value and batch size
py-bitmod [test_value] [batch_size]

Python

# Show help message
python3 py_bitmod.py -h

# Run with optional test value and batch size
python3 py_bitmod.py [test_value] [batch_size]

Dependencies

Building the C extension requires:

  • make — to run build commands
  • gcc — to compile the C source code

About

A lightweight benchmark for measuring different even-checking approaches in Python.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published