Giter VIP home page Giter VIP logo

chainbench's Introduction

Labs

Chainstack is the leading suite of services connecting developers with Web3 infrastructure

         

HomepageSupported protocolsChainstack blogChainstack docsBlockchain API reference
Start for free

Chainbench

checks status build status version license

This project allows you to benchmark your blockchain infrastructure. It uses Locust under the hood.

Project Details

Chainbench lets you to easily define profiles for any EVM-compatible chain. You can use not only hard-coded values but also real chain data to generate dynamic call parameters.

Main features:

  • Built-in profiles for Ethereum, Binance Smart Chain, Polygon, Oasis, and Avalanche
  • Support for custom profiles
  • Dynamic call params generation using real chain data
  • Headless and web UI modes

Check out the docs for more information about the profile creation.

Prerequisites

  • Python 3.10+
  • Poetry 1.2+ (installation instructions here)

Installation

Using pip

pip install chainbench

After installation, you can run the tool using the following command:

chainbench start --help

Using Poetry

Clone the repository:

git clone [email protected]:chainstacklabs/chainbench.git

Install dependencies:

cd chainbench && poetry install --without dev

When installing using Poetry, you can run the tool using the following command:

poetry run chainbench start --help

Example Usage

All the examples below assume that you have installed the tool using pip. If you installed it using poetry, replace chainbench with poetry run chainbench.

To learn about the parameters and flags, run the following command:

chainbench start --help

Basic usage is:

chainbench start --profile bsc --users 50 --workers 2 --test-time 12h --target https://node-url --headless --autoquit

This will run a load test for BSC with 2 workers, 50 users and 12 hours test time in headless mode. After the test is finished, the tool will automatically quit.

Parameters and Flags

  • -p, --profile: Specifies the profile to use for the benchmark. Available profiles can be found in the profile directory. Sample usage -p bsc.general
  • -u, --users: Sets the number of simulated users to use for the benchmark.
  • -w, --workers: Sets the number of worker threads to use for the benchmark.
  • -t, --test-time: Sets the duration of the test to run.
  • --target: Specifies the target blockchain node URL that the benchmark will connect to.
  • --headless: Runs the benchmark in headless mode, meaning that no graphical user interface (GUI) will be displayed during the test. This is useful for running the test on a remote server or when the GUI is not needed.
  • --autoquit: Tells the Chainbench tool to automatically quit after the test has finished. This is useful for running the benchmark in an automated environment where manual intervention is not desired.
  • --help: Displays the help message.
  • -dt, --debug-trace-methods: Enables tasks tagged with debug or trace to be executed
  • -E, --exclude-tags: Exclude tasks tagged with custom tags from the test. You may specify this option multiple times --help Show this message and exit.

You may also run chainbench start --help for the full list of parameters and flags.

Profiles

Default profiles are located in the profile directory. For a tutorial on how to create custom profiles, please refer to this document.

You can also use the -d or --profile-dir flag to specify a custom directory with profiles. For example:

chainbench start --profile-dir /path/to/profiles --profile my-profile --users 50 --workers 2 --test-time 12h --target https://node-url --headless --autoquit

This will run a load test using /path/to/profiles/my-profile.py profile.

It's possible to group profiles into directories. For example, you can create a directory called bsc and put all the BSC profiles there. Then you can run a load test using the following command:

chainbench start --profile-dir /path/to/profiles --profile bsc.my-profile --users 50 --workers 2 --test-time 12h --target https://node-url --headless --autoquit

Chainbench will look for the profile in /path/to/profiles/bsc/my-profile.py. Currently, only one level of nesting is supported.

There are built-in evm.light and evm.heavy profiles for EVM-compatible chains.

Here's an example of how to run a load test for Ethereum using the evm.light profile:

chainbench start --profile evm.light --users 50 --workers 2 --test-time 12h --target https://node-url --headless --autoquit

Web UI Mode

Run the following command to run a load test for BSC in UI mode. It will start a web server on port 8089. Target is required to initialize the test data, however you may change the target endpoint later in the UI, along with the number of users, spawn rate and test time.

chainbench start --profile bsc.general --workers 1 --target https://any-working-node-endpoint.com

Headless Mode

If you want to run a load test for BSC in headless mode, run the following command:

chainbench start --profile bsc --workers 4 --users 100 --test-time 1h --target https://node-url --headless --autoquit

It will run a load test for BSC with 4 workers, 100 users and 1 hour test time.

In practice, you will probably want to run the benchmark on a remote server. Here's the example utilizing nohup:

nohup chainbench start --profile bsc --workers 4 --users 100 --test-time 1h --target https://node-url --headless --autoquit &

License

This project is licensed under the Apache 2.0 License.

chainbench's People

Contributors

ave2me avatar tabascoatw avatar erwin-wee avatar soos3d avatar

Stargazers

Kirill Balakhonov avatar

Forkers

soos3d

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.