-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBenchmark.java
More file actions
68 lines (57 loc) 路 1.75 KB
/
Copy pathBenchmark.java
File metadata and controls
68 lines (57 loc) 路 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
package fastaimcp.benchmark;
import fastaimcp.McpTool;
import fastairuntime.FastAIRuntime;
import fastairuntime.FastCommand;
import fastairuntime.FastObservation;
import fastairuntime.FastTool;
import org.openjdk.jmh.annotations.*;
import java.util.Map;
import java.util.concurrent.TimeUnit;
/**
* JMH Microbenchmark for FastAIMCP.
* Measures tool schema mapping, FastAIRuntime adaptation, and dispatch throughput.
*/
@BenchmarkMode(Mode.Throughput)
@OutputTimeUnit(TimeUnit.MILLISECONDS)
@State(Scope.Benchmark)
@Warmup(iterations = 2, time = 1)
@Measurement(iterations = 3, time = 1)
@Fork(1)
public class Benchmark {
private FastAIRuntime runtime;
private FastCommand command;
@Setup
public void setup() {
runtime = new FastAIRuntime();
McpTool tool = new McpTool(
"read_file",
"Reads file contents via MCP bridge",
Map.of("path", "string")
);
FastTool adapted = new FastTool() {
@Override
public String name() {
return tool.name();
}
@Override
public FastObservation execute(Map<String, Object> args) {
return new FastObservation() {
@Override
public boolean success() {
return true;
}
@Override
public String message() {
return "mock-content";
}
};
}
};
runtime.register(adapted);
command = new FastCommand("read_file", Map.of("path", "README.md"));
}
@Benchmark
public FastObservation benchmarkMcpToolDispatch() {
return runtime.execute(command);
}
}