-
Notifications
You must be signed in to change notification settings - Fork 508
feat: Introduce FastExcel Benchmark Performance Testing Module #575
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
GOODBOY008
wants to merge
2
commits into
apache:main
Choose a base branch
from
GOODBOY008:feat/benchmark-comparison-workflow
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,233 @@ | ||
| # Fesod Benchmark Guide | ||
|
|
||
| This guide provides a comprehensive overview of the Fesod benchmark module, including how to run benchmarks, interpret the results, and contribute new benchmarks. | ||
|
|
||
| ## Overview | ||
|
|
||
| The benchmark module measures and analyzes the performance of Fesod for various Excel operations, such as reading, writing, and filling data. It uses the [Java Microbenchmark Harness (JMH)](https://openjdk.java.net/projects/code-tools/jmh/) to ensure accurate and reliable benchmark results. | ||
|
|
||
| Key goals: | ||
|
|
||
| - Provide a standardized way to measure the performance of Fesod. | ||
| - Track performance regressions and improvements over time. | ||
| - Compare the performance of Fesod with other Excel libraries, such as Apache POI. | ||
| - Help users make informed decisions about how to use Fesod for their specific needs. | ||
|
|
||
| > **Note:** Benchmark code in this module is not part of the Fesod public API. | ||
|
|
||
| ## How to Run Benchmarks | ||
|
|
||
| ### Using the Shade JAR (Recommended) | ||
|
|
||
| Build the uber-jar and run benchmarks directly: | ||
|
|
||
| ```bash | ||
| mvn clean package -f fesod-benchmark/pom.xml -DskipTests | ||
| java -jar fesod-benchmark/target/benchmarks.jar | ||
| ``` | ||
|
|
||
| Run a specific benchmark class: | ||
|
|
||
| ```bash | ||
| java -jar fesod-benchmark/target/benchmarks.jar ReadBenchmark | ||
| ``` | ||
|
|
||
| Run with JMH GC profiler for memory analysis: | ||
|
|
||
| ```bash | ||
| java -jar fesod-benchmark/target/benchmarks.jar -prof gc | ||
| ``` | ||
|
|
||
| Export results as JSON: | ||
|
|
||
| ```bash | ||
| java -jar fesod-benchmark/target/benchmarks.jar -rf json -rff results.json | ||
| ``` | ||
|
|
||
| ### Using the Comparison Runner | ||
|
|
||
| The `ComparisonBenchmarkRunner` provides a pre-configured Fesod vs Apache POI comparison: | ||
|
|
||
| ```bash | ||
| java -cp fesod-benchmark/target/benchmarks.jar \ | ||
| org.apache.fesod.sheet.benchmark.comparison.ComparisonBenchmarkRunner | ||
| ``` | ||
|
|
||
| Results are written to `target/benchmark-results/<session-id>/`. | ||
|
|
||
| ### Using Maven Profiles | ||
|
|
||
| ```bash | ||
| # Run all benchmarks via Maven | ||
| mvn verify -f fesod-benchmark/pom.xml -P benchmark -Dbenchmark.pattern=.* | ||
|
|
||
| # Run a specific benchmark | ||
| mvn verify -f fesod-benchmark/pom.xml -P benchmark -Dbenchmark.pattern=ReadBenchmark | ||
|
|
||
| # Quick CI smoke test (1 fork, 1 iteration, 0 warmup) | ||
| mvn verify -f fesod-benchmark/pom.xml -P benchmark-test | ||
| ``` | ||
|
|
||
| ## Benchmark Suites | ||
|
|
||
| The benchmark module includes the following suites: | ||
|
|
||
| | Suite | Description | | ||
| |---|---| | ||
| | **Comparison** | Head-to-head comparison of Fesod vs Apache POI for read, write, and streaming operations | | ||
| | **Operations** | Focused benchmarks for read (`ReadBenchmark`), write (`WriteBenchmark`), and fill (`FillBenchmark`) operations | | ||
|
|
||
| ### Dataset Sizes | ||
|
|
||
| | Size | Rows | Use Case | | ||
| |---|---|---| | ||
| | `SMALL` | 1,000 | Quick development feedback | | ||
| | `MEDIUM` | 10,000 | Standard CI benchmarks | | ||
| | `LARGE` | 100,000 | Performance analysis | | ||
| | `EXTRA_LARGE` | 1,000,000 | Stress testing (comparison benchmarks only) | | ||
|
|
||
| ## JMH Best Practices Applied | ||
|
|
||
| This benchmark module follows JMH best practices: | ||
|
|
||
| 1. **No manual timing** - JMH handles all timing measurements via `@BenchmarkMode`. | ||
| 2. **No `System.gc()` calls** - Avoids unpredictable pauses that distort measurements. | ||
| 3. **Fixed heap size** - `-Xms` equals `-Xmx` for stable GC behavior. | ||
| 4. **Pre-loaded data** - All test data is generated in `@Setup(Level.Trial)` to exclude I/O from measurements. | ||
| 5. **Fixed random seed** - Ensures reproducible data generation across runs. | ||
| 6. **Fair comparison** - Both Fesod and Apache POI write/read the same columns. | ||
| 7. **`Blackhole.consume()`** - Prevents dead code elimination by the JIT compiler. | ||
| 8. **`@OperationsPerInvocation`** - Allows JMH to correctly calculate throughput. | ||
|
|
||
| ## Interpreting Results | ||
|
|
||
| JMH produces output in the following format: | ||
|
|
||
| ``` | ||
| Benchmark (datasetSize) (fileFormat) Mode Cnt Score Error Units | ||
| FastExcelVsPoiBenchmark.benchmarkFesodRead SMALL XLSX avgt 5 2.345 ± 0.123 ms/op | ||
| FastExcelVsPoiBenchmark.benchmarkPoiRead SMALL XLSX avgt 5 5.678 ± 0.456 ms/op | ||
| ``` | ||
|
|
||
| Key columns: | ||
| - **Mode**: `avgt` (average time), `thrpt` (throughput), `ss` (single shot) | ||
| - **Score**: The benchmark score (lower is better for `avgt`, higher for `thrpt`) | ||
| - **Error**: 99% confidence interval | ||
| - **Units**: `ms/op` (milliseconds per operation), `ops/s` (operations per second) | ||
| # FastExcel Benchmark Guide | ||
|
|
||
| This guide provides a comprehensive overview of the FastExcel benchmark module, including how to run benchmarks, interpret the results, and contribute new benchmarks. | ||
|
|
||
| ## Overview | ||
|
|
||
| The benchmark module is designed to measure and analyze the performance of FastExcel for various Excel operations, such as reading, writing, and filling data. It uses the [Java Microbenchmark Harness (JMH)](https://openjdk.java.net/projects/code-tools/jmh/) to ensure accurate and reliable benchmark results. | ||
|
|
||
| The key goals of the benchmark module are: | ||
|
|
||
| - To provide a standardized way to measure the performance of FastExcel. | ||
| - To track performance regressions and improvements over time. | ||
| - To compare the performance of FastExcel with other Excel libraries, such as Apache POI. | ||
| - To help users make informed decisions about how to use FastExcel for their specific needs. | ||
|
|
||
| ## How to Run Benchmarks | ||
|
|
||
| There are two primary ways to run the benchmarks: using the `benchmark-runner.sh` script or using Maven profiles. | ||
|
|
||
| ### Using the `benchmark-runner.sh` Script | ||
|
|
||
| The `benchmark-runner.sh` script provides a convenient way to run the benchmarks with various options. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| ./fastexcel-benchmark/scripts/benchmark-runner.sh [OPTIONS] | ||
| ``` | ||
|
|
||
| **Options:** | ||
|
|
||
| | Option | Description | Default | | ||
| |---|---|---| | ||
| | `-p`, `--profile` | Benchmark profile (quick, standard, comprehensive) | `standard` | | ||
| | `-o`, `--output` | Output directory for results | `benchmark-results` | | ||
| | `-j`, `--java-version` | Java version to use | `11` | | ||
| | `-m`, `--memory` | JVM heap size | `4g` | | ||
| | `-t`, `--pattern` | Benchmark pattern to match | | | ||
| | `-d`, `--dataset` | Dataset size (SMALL, MEDIUM, LARGE, EXTRA_LARGE, ALL) | `ALL` | | ||
| | `-f`, `--format` | Output format (json, csv, text) | `json` | | ||
| | `-r`, `--regression` | Enable regression analysis | | | ||
| | `-v`, `--verbose` | Enable verbose output | | | ||
| | `-h`, `--help` | Show this help message | | | ||
|
|
||
| **Profiles:** | ||
|
|
||
| - `quick`: Fast execution for development (2 warmup, 3 measurement, 1 fork). | ||
| - `standard`: Balanced execution for CI (3 warmup, 5 measurement, 1 fork). | ||
| - `comprehensive`: Thorough execution for nightly (5 warmup, 10 measurement, 2 forks). | ||
|
|
||
| **Examples:** | ||
|
|
||
| - Run standard benchmarks: | ||
| ```bash | ||
| ./fastexcel-benchmark/scripts/benchmark-runner.sh --profile standard | ||
| ``` | ||
| - Run quick benchmarks for read operations only: | ||
| ```bash | ||
| ./fastexcel-benchmark/scripts/benchmark-runner.sh --profile quick --pattern "ReadBenchmark" | ||
| ``` | ||
| - Run comprehensive benchmarks with regression analysis: | ||
| ```bash | ||
| ./fastexcel-benchmark/scripts/benchmark-runner.sh --profile comprehensive --regression | ||
| ``` | ||
|
|
||
| ### Using Maven Profiles | ||
|
|
||
| You can also run the benchmarks using Maven profiles. This is useful for integrating the benchmarks into a CI/CD pipeline. | ||
|
|
||
| **Usage:** | ||
|
|
||
| ```bash | ||
| mvn clean install -f fastexcel-benchmark/pom.xml -P <profile> -Dbenchmark.pattern=<pattern> | ||
| ``` | ||
|
|
||
| **Profiles:** | ||
|
|
||
| - `benchmark`: The primary profile for running benchmarks. | ||
|
|
||
| **Examples:** | ||
|
|
||
| - Run all benchmarks: | ||
| ```bash | ||
| mvn clean install -f fastexcel-benchmark/pom.xml -P benchmark | ||
| ``` | ||
| - Run a specific benchmark: | ||
| ```bash | ||
| mvn clean install -f fastexcel-benchmark/pom.xml -P benchmark -Dbenchmark.pattern=ReadBenchmark | ||
| ``` | ||
|
|
||
| ## Benchmark Suites | ||
|
|
||
| The benchmark module includes the following suites: | ||
|
|
||
| - **Comparison:** Benchmarks comparing FastExcel with other libraries (e.g., Apache POI). | ||
| - **Config:** Benchmarks related to configuration options. | ||
| - **Core:** Core benchmark classes and utilities. | ||
| - **Data:** Benchmarks related to data handling and processing. | ||
| - **Memory:** Benchmarks focused on memory usage. | ||
| - **Operations:** Benchmarks for specific operations like read, write, and fill. | ||
| - **Streaming:** Benchmarks for streaming operations. | ||
|
|
||
| ## Interpreting Results | ||
|
|
||
| The benchmarks produce output in the format specified by the `--format` option. The default format is JSON. | ||
|
|
||
| The output includes the following information: | ||
|
|
||
| - **Benchmark:** The name of the benchmark. | ||
| - **Mode:** The benchmark mode (e.g., `thrpt` for throughput, `avgt` for average time). | ||
| - **Threads:** The number of threads used. | ||
| - **Forks:** The number of forks used. | ||
| - **Warmup Iterations:** The number of warmup iterations. | ||
| - **Measurement Iterations:** The number of measurement iterations. | ||
| - **Score:** The benchmark score. | ||
| - **Score Error:** The error of the benchmark score. | ||
| - **Unit:** The unit of the benchmark score (e.g., `ops/s` for operations per second). | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Documentation references
benchmark-runner.shscript infastexcel-benchmark/scripts/directory, but this script does not exist in the PR. Either the script needs to be added or the documentation should be updated to remove references to it.