GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - albahrani/nanoid-java-benchmark: Benchmark suite for nanoid-java using JMH.

BranchesTags
Open more actions menu

Latest commit

 

History

2 Commits
2 Commits

Folders and files

NameName
Last commit message
Last commit date
.github
.github
 
 
src/main/java/com/nanoid
src/main/java/com/nanoid
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
CONTRIBUTING.md
CONTRIBUTING.md
 
 
LICENSE
LICENSE
 
 
README.md
README.md
 
 
SECURITY.md
SECURITY.md
 
 
pom.xml
pom.xml
 
 

Repository files navigation

NanoID Java Benchmark

License: MIT

A comprehensive benchmark suite for nanoid-java using JMH (Java Microbenchmark Harness), providing performance measurements for NanoID generation operations.

Overview

This project benchmarks the performance of the nanoid-java library, measuring throughput and timing statistics for various NanoID generation scenarios.

Prerequisites

  • JDK 17 or higher
  • Apache Maven 3.6.0 or higher

Quick Start

  1. Clone the repository:

    git clone https://github.com/albahrani/nanoid-java-benchmark.git
    cd nanoid-java-benchmark
  2. Build the project:

    mvn clean compile
  3. Run all benchmarks:

    mvn exec:java

Benchmark Scenarios

The benchmark suite includes the following test scenarios:

Benchmark Description Method
Default NanoID Standard 21-character NanoID with default alphabet NanoId.nanoid()
Custom Length 10-character NanoID with default alphabet NanoId.nanoid(10)
Custom Alphabet 21-character NanoID with custom alphabet (abcdef) NanoId.customNanoid("abcdef", 21)

Running Specific Benchmarks

You can run specific benchmarks using JMH's filtering capabilities:

# Run only default NanoID benchmark
mvn exec:java -Dexec.args=".*generateDefaultNanoId.*"

# Run only custom length benchmark
mvn exec:java -Dexec.args=".*generateNanoId10.*"

# Run only custom alphabet benchmark
mvn exec:java -Dexec.args=".*generateCustomNanoId.*"

Benchmark Configuration

The benchmarks are configured with the following JMH settings:

  • Warmup: 2 iterations
  • Measurement: 5 iterations
  • Fork: 0 (disabled for classpath compatibility)
  • Time Unit: Microseconds
  • State: Benchmark scope

Understanding the Output

JMH will output performance metrics including:

  • Throughput: Operations per second (ops/s)
  • Average Time: Average execution time per operation
  • Error: Statistical error margin
  • Score: Benchmark score with confidence intervals

Example output:

Benchmark                                  Mode  Cnt    Score   Error  Units
NanoIdBenchmark.generateDefaultNanoId     thrpt    5  123.456 ± 7.890  ops/us
NanoIdBenchmark.generateNanoId10          thrpt    5  234.567 ± 8.901  ops/us
NanoIdBenchmark.generateCustomNanoId      thrpt    5  345.678 ± 9.012  ops/us

Advanced Configuration

Custom JMH Parameters

You can customize benchmark execution with additional JMH parameters:

# Run with custom iterations
mvn exec:java -Dexec.args="-wi 5 -i 10"

# Generate detailed reports
mvn exec:java -Dexec.args="-rf json -rff benchmark-results.json"

# Run with profilers
mvn exec:java -Dexec.args="-prof gc"

Available Profilers

  • gc: Garbage collection profiling
  • stack: Stack profiling
  • perf: Performance counter profiling (Linux only)

Project Structure

nanoid-java-benchmark/
├── src/
│   └── main/
│       └── java/
│           └── com/
│               └── nanoid/
│                   └── NanoIdBenchmark.java
├── pom.xml
├── README.md
├── LICENSE
└── .gitignore

Dependencies

  • nanoid-java: Core NanoID implementation
  • JMH Core: Microbenchmark harness
  • JMH Annotation Processor: JMH code generation

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Related Projects

  • nanoid-java - Java implementation of NanoID
  • nanoid - Original JavaScript implementation

License

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

About

Benchmark suite for nanoid-java using JMH.

Resources

Readme
MIT license

Contributing

Contributing

Security policy

Security policy
Activity

Stars

1 star

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.