feat: add benchmark for Wren C API foreign method calls and refactor test class names
Add a new benchmark that measures the performance of calling foreign methods through the Wren C embedding API, specifically testing argument passing and return values with a tight loop of 10 million calls. Refactor test API classes from generic "Api" to specific names like "Call", "Returns", "Value", and "ForeignClass" to avoid naming conflicts with the new benchmark module. Update the benchmark runner to use the test_api executable for API-specific benchmarks and remove the special API test argument handling from the test runner.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
class Benchmark {
|
||||
foreign static arguments(a, b, c, d)
|
||||
}
|
||||
|
||||
var start = System.clock
|
||||
var result = 0
|
||||
for (i in 1..1000000) {
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
result = result + Benchmark.arguments(1, 2, 3, 4)
|
||||
}
|
||||
System.print(result)
|
||||
System.print("elapsed: %(System.clock - start)")
|
||||
Reference in New Issue
Block a user