forked from Mirror/wren
Add a benchmark to test the Wren C API.
I've got some ideas on how to tweak the embedding API, but I want to see what performance impact they have first, so this adds a little benchmark that just calls a foreign method a ton of times.
This commit is contained in:
20
test/benchmark/api_foreign_method.wren
Normal file
20
test/benchmark/api_foreign_method.wren
Normal file
@ -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