Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Performance Benchmark Workflow
# This workflow runs performance benchmarks and reports results

name: Performance Benchmarks

on:
# Run on pushes to main branch
push:
branches: [ main ]
# Run on pull requests targeting main branch
pull_request:
branches: [ main ]
# Allow manual triggering
workflow_dispatch:

jobs:
benchmark:
runs-on: ubuntu-latest
# Only run on main branch pushes or manual trigger
if: github.event_name == 'push' && github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch'

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Fetch all history for trend analysis

- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: maven

- name: Build Project
run: mvn clean compile

- name: Run Performance Benchmarks
run: mvn test -Pbenchmark -Dtest.benchmark=true

- name: Upload Benchmark Results
uses: actions/upload-artifact@v4
with:
name: benchmark-results
path: target/benchmark-reports/

- name: Store Benchmark Baseline
# This step would store the results as a baseline for future comparisons
run: |
echo "Storing benchmark results as baseline"
# In a real implementation, this would upload results to a storage service
# or commit them to a dedicated branch/repository for baselines

- name: Compare with Baseline
# This step would compare current results with stored baseline
run: |
echo "Comparing benchmark results with baseline"
# In a real implementation, this would run comparison scripts
# and fail the workflow if regressions are detected

- name: Comment PR with Results
if: github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
script: |
const fs = require('fs');
// In a real implementation, this would read the actual benchmark results
const report = `
## Performance Benchmark Results

### Summary
- Agent Call Performance: 12.5ms avg
- Memory Operations: 0.8ms avg
- Tool Execution: 3.2ms avg

### Details
See full report in artifacts.
`;

github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: report
});
30 changes: 30 additions & 0 deletions agentscope-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,34 @@
</dependency>

</dependencies>

<profiles>
<!-- Profile for running performance benchmarks -->
<profile>
<id>benchmark</id>
<dependencies>
<!-- JMH dependencies for benchmarking -->
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-core</artifactId>
</dependency>
<dependency>
<groupId>org.openjdk.jmh</groupId>
<artifactId>jmh-generator-annprocess</artifactId>
</dependency>

<!-- Micrometer dependencies for metrics collection -->
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-core</artifactId>
</dependency>

<!-- JSON processing for reporting -->
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
/*
* Copyright 2024-2025 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.agentscope.core.benchmark;

/**
* Configuration class for benchmark execution parameters.
*/
public class BenchmarkConfig {

// Default values
private static final int DEFAULT_WARMUP_ITERATIONS = 3;
private static final int DEFAULT_WARMUP_TIME_SECONDS = 10;
private static final int DEFAULT_MEASUREMENT_ITERATIONS = 5;
private static final int DEFAULT_MEASUREMENT_TIME_SECONDS = 10;
private static final int DEFAULT_THREAD_COUNT = 1;
private static final int DEFAULT_FORK_COUNT = 1;
private static final boolean DEFAULT_ENABLE_PROFILING = false;

private int warmupIterations = DEFAULT_WARMUP_ITERATIONS;
private int warmupTimeSeconds = DEFAULT_WARMUP_TIME_SECONDS;
private int measurementIterations = DEFAULT_MEASUREMENT_ITERATIONS;
private int measurementTimeSeconds = DEFAULT_MEASUREMENT_TIME_SECONDS;
private int threadCount = DEFAULT_THREAD_COUNT;
private int forkCount = DEFAULT_FORK_COUNT;
private boolean enableProfiling = DEFAULT_ENABLE_PROFILING;

public BenchmarkConfig() {
// Default constructor
}

// Getters and setters

public int getWarmupIterations() {
return warmupIterations;
}

public void setWarmupIterations(int warmupIterations) {
this.warmupIterations = warmupIterations;
}

public int getWarmupTimeSeconds() {
return warmupTimeSeconds;
}

public void setWarmupTimeSeconds(int warmupTimeSeconds) {
this.warmupTimeSeconds = warmupTimeSeconds;
}

public int getMeasurementIterations() {
return measurementIterations;
}

public void setMeasurementIterations(int measurementIterations) {
this.measurementIterations = measurementIterations;
}

public int getMeasurementTimeSeconds() {
return measurementTimeSeconds;
}

public void setMeasurementTimeSeconds(int measurementTimeSeconds) {
this.measurementTimeSeconds = measurementTimeSeconds;
}

public int getThreadCount() {
return threadCount;
}

public void setThreadCount(int threadCount) {
this.threadCount = threadCount;
}

public int getForkCount() {
return forkCount;
}

public void setForkCount(int forkCount) {
this.forkCount = forkCount;
}

public boolean isEnableProfiling() {
return enableProfiling;
}

public void setEnableProfiling(boolean enableProfiling) {
this.enableProfiling = enableProfiling;
}

/**
* Create a default configuration
*
* @return a new BenchmarkConfig instance with default values
*/
public static BenchmarkConfig createDefault() {
return new BenchmarkConfig();
}

/**
* Create a configuration for quick testing
*
* @return a new BenchmarkConfig instance with reduced iterations for quick testing
*/
public static BenchmarkConfig createQuickTest() {
BenchmarkConfig config = new BenchmarkConfig();
config.setWarmupIterations(1);
config.setWarmupTimeSeconds(2);
config.setMeasurementIterations(2);
config.setMeasurementTimeSeconds(3);
return config;
}

/**
* Create a configuration for thorough testing
*
* @return a new BenchmarkConfig instance with increased iterations for thorough testing
*/
public static BenchmarkConfig createThoroughTest() {
BenchmarkConfig config = new BenchmarkConfig();
config.setWarmupIterations(5);
config.setWarmupTimeSeconds(15);
config.setMeasurementIterations(10);
config.setMeasurementTimeSeconds(15);
config.setForkCount(2);
return config;
}
}
Loading
Loading