Demo app for multi-threaded method benchmark.
- Introduction
- Features
- Modules
- Profiles
- Logging
- Installation
- Extending Test Cases
- Configuration
- Benchmarking
threadBenchmark is a project designed to benchmark multi-threaded methods. It allows users to measure the performance of various methods under different threading conditions.
- Benchmark multi-threaded methods.
- Easy configuration and setup.
- Detailed performance reports.
The project consists of the following modules:
- Benchmark: This module contains the benchmark tests.
- ThreadBenchmarkApplication: This is the main application module that is being tested.
- JmeterPerformanceApplication: This module contains a very simple application that allows you to test it using jmeter.
The application supports profiles to configure the environment. The "dev" profile is available. Activating this profile switches the logging level to trace. This is the basic functionality for demonstrating the capabilities of profiles in Spring Boot.
- Run profile "dev" add following parameter to VM:
-Dspring.profiles.active=dev
- logback-spring.xml: This file is used to configure logging for different profiles.
To install and run the threadBenchmark application, follow these steps:
-
Clone the repository:
git clone https://github.com/DamianOzga/threadBenchmark.git cd threadBenchmark -
Build the project:
./mvn clean compile ./mvn package
-
Run the Benchmark module:
Run main method from IDE level (MethodBenchmarkRunner.java). -
Run the ThreadBenchmarkApplication module:
# Run main method from IDE level Main class for running the Thread Benchmark Application. ThreadBenchmarkApp.java # Build the Docker image cd ./ThreadBenchmarkApplication docker build -t thread-benchmark . # Run the application using Docker Compose cd ./ThreadBenchmarkApplication docker-compose up # Close Docker Compose docker-compose down
-
Run the JmeterPerformanceApplication module:
./mvn clean compile ./mvn package copy JmeterPerformanceApplication-**-dependencies.jar file to jmeter lib/ext folder and write your own Test Plans
To use the threadBenchmark application, you need to define the methods you want to benchmark and configure the threading parameters. Here is a simple example:
-
Define your benchmark class:
package com.example.benchmark; import com.interview.damian_ozga.benchmark.AbstractThreadBenchmark; public class MyBenchmark extends AbstractThreadBenchmark { @Override public void setup() { // Setup code here } @Override public void codeToTest() { // Method to benchmark } }
-
Include to runner configuration:
Options opt = new OptionsBuilder() .include(MyBenchmark.class.getSimpleName()) ... .build();
You can configure various parameters for the benchmark, such as the number of threads, iterations, and more. Configuration is done through properties files or command-line arguments.
The application provides detailed performance reports after executing the benchmarks. These reports include metrics such as execution time, throughput, and resource utilization.