Skip to content

Commit 824df2e

Browse files
committed
span size perf test
1 parent 726cf7e commit 824df2e

5 files changed

Lines changed: 419 additions & 0 deletions

File tree

perf-tests/build.gradle

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
plugins {
2+
id 'java'
3+
}
4+
5+
java {
6+
toolchain {
7+
languageVersion = JavaLanguageVersion.of(17)
8+
vendor = JvmVendorSpec.ADOPTIUM
9+
}
10+
}
11+
12+
repositories {
13+
mavenCentral()
14+
}
15+
16+
def langchainVersion = '1.8.0'
17+
18+
ext {
19+
otelVersion = rootProject.ext.otelVersion
20+
junitVersion = rootProject.ext.junitVersion
21+
slf4jVersion = rootProject.ext.slf4jVersion
22+
}
23+
24+
dependencies {
25+
testImplementation project(":braintrust-sdk")
26+
testImplementation project(":braintrust-sdk:instrumentation:langchain_1_8_0")
27+
testImplementation project(":braintrust-java-agent:instrumenter")
28+
testImplementation(testFixtures(project(":test-harness")))
29+
30+
testImplementation "io.opentelemetry:opentelemetry-api:${otelVersion}"
31+
testImplementation "io.opentelemetry:opentelemetry-sdk:${otelVersion}"
32+
testImplementation "io.opentelemetry:opentelemetry-sdk-trace:${otelVersion}"
33+
testImplementation "io.opentelemetry:opentelemetry-sdk-logs:${otelVersion}"
34+
testImplementation "io.opentelemetry:opentelemetry-sdk-metrics:${otelVersion}"
35+
36+
testImplementation "dev.langchain4j:langchain4j:${langchainVersion}"
37+
testImplementation "dev.langchain4j:langchain4j-http-client:${langchainVersion}"
38+
testImplementation "dev.langchain4j:langchain4j-open-ai:${langchainVersion}"
39+
40+
testImplementation 'net.bytebuddy:byte-buddy-agent:1.17.5'
41+
42+
testImplementation "org.junit.jupiter:junit-jupiter:${junitVersion}"
43+
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
44+
testRuntimeOnly "org.slf4j:slf4j-simple:${slf4jVersion}"
45+
}
46+
47+
// Disable the default test task so perf tests don't run during ./gradlew test or check.
48+
// Run explicitly with: ./gradlew :perf-tests:perfTest
49+
test {
50+
enabled = false
51+
}
52+
53+
task perfTest(type: Test) {
54+
useJUnitPlatform()
55+
workingDir = rootProject.projectDir
56+
57+
// Performance tests can be slow — give them generous timeouts
58+
systemProperty 'junit.jupiter.execution.timeout.default', '120s'
59+
60+
testLogging {
61+
events "passed", "skipped", "failed"
62+
showStandardStreams = true
63+
exceptionFormat "full"
64+
}
65+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
package dev.braintrust.perf;
2+
3+
/**
4+
* Captures the result of a single performance test run.
5+
*
6+
* @param config the configuration that produced this result
7+
* @param payloadBytes total bytes of the OTLP HTTP request body captured at the wire
8+
* @param spanCount number of spans that were exported (as observed by the server)
9+
* @param requestCount number of HTTP requests received by the capture server
10+
*/
11+
public record PerfResult(PerfRunConfig config, long payloadBytes, int spanCount, int requestCount) {
12+
13+
/** Bytes per span (approximate). */
14+
public double bytesPerSpan() {
15+
return spanCount > 0 ? (double) payloadBytes / spanCount : 0;
16+
}
17+
18+
public double payloadMB() {
19+
return payloadBytes / (1024.0 * 1024.0);
20+
}
21+
22+
public String summary() {
23+
return String.format(
24+
"[%s] %d request(s), %d span(s), %.3f MB total (%.1f bytes/span)",
25+
config.name(), requestCount, spanCount, payloadMB(), bytesPerSpan());
26+
}
27+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package dev.braintrust.perf;
2+
3+
/**
4+
* Describes the configuration for a single performance test run.
5+
*
6+
* <p>Each field controls the shape of the multi-turn conversation that will be generated and
7+
* exported. Add new fields here as you add new scenarios (e.g. tool use, streaming, etc.).
8+
*
9+
* @param name human-readable label for this configuration
10+
* @param turns number of conversational turns (user messages sent to the AI service)
11+
* @param includeImageAttachment whether to include an image attachment in the first user message
12+
*/
13+
public record PerfRunConfig(String name, int turns, boolean includeImageAttachment) {
14+
15+
/** A multi-turn conversation with an image attachment on the first turn. */
16+
public static PerfRunConfig multiTurnWithAttachment() {
17+
return new PerfRunConfig("multi-turn-with-attachment", 10, true);
18+
}
19+
20+
/** A multi-turn conversation with text only (no attachments). */
21+
public static PerfRunConfig multiTurnTextOnly() {
22+
return new PerfRunConfig("multi-turn-text-only", 3, false);
23+
}
24+
}

0 commit comments

Comments
 (0)