Skip to content

Commit 5c778df

Browse files
committed
perf: trim tracer E2E workload to single function (repeatString)
Keep only repeatString which reliably produces 284% improvement. Drop computeSum (marginal 16%), filterEvens and instanceMethod (no optimization found). Reduces tracer E2E from ~1h27m to ~21m.
1 parent 40f16b5 commit 5c778df

1 file changed

Lines changed: 1 addition & 43 deletions

File tree

  • tests/test_languages/fixtures/java_tracer_e2e/src/main/java/com/example
Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,7 @@
11
package com.example;
22

3-
import java.util.ArrayList;
4-
import java.util.List;
5-
63
public class Workload {
74

8-
public static int computeSum(int n) {
9-
int sum = 0;
10-
for (int i = 0; i < n; i++) {
11-
sum += i;
12-
}
13-
return sum;
14-
}
15-
165
public static String repeatString(String s, int count) {
176
String result = "";
187
for (int i = 0; i < count; i++) {
@@ -21,46 +10,15 @@ public static String repeatString(String s, int count) {
2110
return result;
2211
}
2312

24-
public static List<Integer> filterEvens(List<Integer> numbers) {
25-
List<Integer> result = new ArrayList<>();
26-
for (int n : numbers) {
27-
if (n % 2 == 0) {
28-
result.add(n);
29-
}
30-
}
31-
return result;
32-
}
33-
34-
public int instanceMethod(int x, int y) {
35-
return x * y + computeSum(x);
36-
}
37-
3813
public static void main(String[] args) {
39-
// Run methods with large inputs so JFR can capture CPU samples.
40-
// Small inputs finish too fast (<1ms) for JFR's 10ms sampling interval.
14+
// Run with large inputs so JFR can capture CPU samples.
4115
for (int round = 0; round < 1000; round++) {
42-
computeSum(100_000);
4316
repeatString("hello world ", 1000);
44-
45-
List<Integer> nums = new ArrayList<>();
46-
for (int i = 1; i <= 10_000; i++) nums.add(i);
47-
filterEvens(nums);
48-
49-
Workload w = new Workload();
50-
w.instanceMethod(100_000, 42);
5117
}
5218

5319
// Also call with small inputs for variety in traced args
54-
System.out.println("computeSum(100) = " + computeSum(100));
5520
System.out.println("repeatString(\"ab\", 3) = " + repeatString("ab", 3));
5621

57-
List<Integer> small = new ArrayList<>();
58-
for (int i = 1; i <= 10; i++) small.add(i);
59-
System.out.println("filterEvens(1..10) = " + filterEvens(small));
60-
61-
Workload w = new Workload();
62-
System.out.println("instanceMethod(5, 3) = " + w.instanceMethod(5, 3));
63-
6422
System.out.println("Workload complete.");
6523
}
6624
}

0 commit comments

Comments
 (0)