Skip to main content

Python PyPI pre-commit Code style: black codecov

NxBench

NxBench Logo

nxbench is a comprehensive benchmarking suite designed to facilitate comparative profiling of graph analytic algorithms across NetworkX and compatible backends. Built using Prefect and Dask, nxbench places an emphasis on extensible and granular performance analysis, enabling developers and researchers to optimize their graph analysis workflows efficiently and reproducibly.

Key Features

  • Cross-Backend Benchmarking: Leverage NetworkX's backend system to profile algorithms across multiple implementations (NetworkX, nx-parallel, GraphBLAS, and CuGraph)
  • Configurable Suite: YAML-based configuration for algorithms, datasets, and benchmarking parameters
  • Real-World Datasets: Automated downloading and caching of networks and their metadata from NetworkRepository
  • Synthetic Graph Generation: Support for generating benchmark graphs using any of NetworkX's built-in generators
  • Validation Framework: Comprehensive result validation for correctness across implementations
  • Performance Monitoring: Track execution time and memory usage with detailed metrics
  • Interactive Visualization: Dynamic dashboard for exploring benchmark results using Plotly Dash
  • Flexible Storage: SQL result storage with pandas integration for dowstream analysis

Installation (Non-Docker Setup)

Prerequisites

  • Python 3.10+: Ensure you have a compatible Python environment.
  • PostgreSQL: To run Prefect Orion with a persistent database, we recommend PostgreSQL for better concurrency and stability than an ephemeral in-memory database.
  • NetworkX Backend Installations: To comparative benchmark graph algorithm performance across different NetworkX backends, you will need to install each backend.

Setting up PostgreSQL

In a terminal window:

  1. Install PostgreSQL:

    • On macOS (with Homebrew):

      brew install postgresql
      brew services start postgresql
      
    • On Linux (Debian/Ubuntu):

      sudo apt-get update && sudo apt-get install -y postgresql postgresql-contrib
      sudo service postgresql start
      
    • On Windows: Download and run the PostgreSQL installer and follow the prompts.

  2. Create a PostgreSQL User and Database:

    psql postgres
    

    In the psql prompt, run:

    CREATE USER prefect_user WITH PASSWORD 'pass';
    
    CREATE DATABASE prefect_db OWNER prefect_user;
    GRANT ALL PRIVILEGES ON DATABASE prefect_db TO prefect_user;
    

    Exit the prompt with \q.

    This sets up a prefect_user with password pass and a database named prefect_db.

Supported Backends

  • NetworkX (default)
  • nx-CuGraph (requires separate CuGraph installation and supported GPU hardware)
  • GraphBLAS Algorithms (optional)
  • nx-parallel (optional)

Installing nxbench

In a new terminal window:

PyPi:

pip install nxbench

From source (local clone):

git clone https://github.com/dpys/nxbench.git
cd nxbench
make install

This should install nxbench and all required dependencies (including prefect, asyncpg, and related packages).

Installation (Docker Setup)

Docker:

# CPU-only
make build

# With GPU
make build-gpu

Quick Start

  1. Configure your benchmarks in a yaml file (see configs/example.yaml):
algorithms:
  - name: "pagerank"
    func: "networkx.pagerank"
    params:
      alpha: 0.85
    groups: ["centrality"]

datasets:
  - name: "karate"
    source: "networkrepository"
  1. Start an instance of an orion server in a separate terminal window:
export PREFECT_API_URL="http://127.0.0.1:4200/api"
export PREFECT_API_DATABASE_CONNECTION_URL="postgresql+asyncpg://prefect_user:pass@localhost:5432/prefect_db"
prefect server start
  1. In the original terminal window, run benchmarks based on the configuration:
nxbench --config 'nxbench/configs/example.yaml' benchmark run
  1. Export results:
nxbench --config 'nxbench/configs/example.yaml' benchmark export 'results/9e3e8baa4a3443c392dc8fee00373b11_20241220002902.json' --output-format csv --output-file 'results/results.csv'  # convert benchmarked results from a run with hash `9e3e8baa4a3443c392dc8fee00373b11_20241220002902` into csv format.
  1. View results:
nxbench viz serve  # launch the interactive results visualization dashboard.

Parallel Categories Animation

Advanced Command Line Interface

The CLI provides comprehensive management of benchmarks, datasets, and visualization:

# Data Management
nxbench data download karate  # download specific dataset
nxbench data list --category social  # list available datasets

# Benchmarking
nxbench --config 'nxbench/configs/example.yaml' -vvv benchmark run  # debug benchmark runs
nxbench --config 'nxbench/configs/example.yaml' benchmark export 'results/9e3e8baa4a3443c392dc8fee00373b11_20241220002902.json' --output-format sql # export the results from a run with hash `9e3e8baa4a3443c392dc8fee00373b11_20241220002902` into postgres sql

Configuration

Benchmarks are configured through YAML files with the following structure:

algorithms:
  - name: "algorithm_name"
    func: "fully.qualified.function.name"
    params: {}
    requires_directed: false
    groups: ["category"]
    validate_result: "validation.function"

datasets:
  - name: "dataset_name"
    source: "networkrepository"
    params: {}

Reproducible benchmarking through docker

Instead of invoking docker-compose directly, we provide a convenience script (docker/nxbench-run.sh) to run each of the nxbench commands. This script automatically:

  • Resolves and mounts your configuration file.
  • Switches between CPU and GPU modes using the --gpu flag.
  • Detects the desired subcommand (benchmark run/export, viz, data download/list, etc.)
  • Mounts your host's results directory when needed.
# Download a Dataset (e.g. Karate):
docker/nxbench-run.sh --config 'nxbench/configs/example.yaml' data download karate

# List Available Datasets by Category:
docker/nxbench-run.sh --config 'nxbench/configs/example.yaml' data list --category social

# Run benchmarks
docker/nxbench-run.sh --config 'nxbench/configs/example.yaml' benchmark run

# Run benchmarks (with GPU support)
docker/nxbench-run.sh --gpu --config 'nxbench/configs/example.yaml' benchmark run

# Export Benchmark Results to CSV:
docker/nxbench-run.sh --config 'nxbench/configs/example.yaml' benchmark export 'nxbench_results/9e3e8baa4a3443c392dc8fee00373b11_20241220002902.json' --output-format csv --output-file 'nxbench_results/results.csv'

# Launch the Visualization Dashboard:
docker/nxbench-run.sh --config 'nxbench/configs/example.yaml' viz serve
# Note: The dashboard service requires that benchmark results have been generated and exported (i.e. a valid results/results.csv file
# exists).

Contributing

Contributions are welcome! Please read our Contributing Guide for details on:

  • Code style guidelines
  • Development setup
  • Testing requirements
  • Pull request process

License

This project is licensed under the MIT License - see LICENSE for details.

Acknowledgments

  • NetworkX community for the core graph library and dispatching support
  • NetworkRepository.com for harmonized dataset access

Contact

For questions or suggestions:

Metadata

Release files for nxbench 0.1.25

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for nxbench 0.1.25
File Size Uploaded Provenance Actions
nxbench-0.1.25.tar.gz 180.9 kB Without provenance Details for nxbench-0.1.25.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for nxbench 0.1.25
File Interpreter ABI Platform Actions
nxbench-0.1.25-py3-none-any.whl Python 3 none any Details for nxbench-0.1.25-py3-none-any.whl

Total release size: 364.9 kB

Release files / nxbench-0.1.25.tar.gz

Download URL nxbench-0.1.25.tar.gz
Size 180.9 kB
Tags Source
SHA-256 checksum
How to use checksums
3ec851f5c60f65ce7d2d50912e4494f274ad6e55ef19e1e2a08a0b706cc9b8de
BLAKE2b-256 checksum
How to use checksums
efc0d07524fe2d013bbc34f1c703989bda46c4f80f0b1cac8d26b39e259d80c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Release files / nxbench-0.1.25-py3-none-any.whl

Download URL nxbench-0.1.25-py3-none-any.whl
Size 184.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83a5c3f8cef836bf07e74296f370ec2c17511a3a87c71c10927d6de3294b88c9
BLAKE2b-256 checksum
How to use checksums
8f2749b0ec1de09b54c8b57e823a65abed06dce5e9c20441ecbc067d579b0a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.9.21

Security for nxbench 0.1.25

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page