-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Correctly offset the arguments to calls (to make room for
this
alwa…
…ys being the first argument).
- Loading branch information
Showing
6 changed files
with
60 additions
and
36 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
part-13/src/jmh/java/com/endoflineblog/truffle/part_13/FibonacciBenchmark.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package com.endoflineblog.truffle.part_13; | ||
|
||
import org.openjdk.jmh.annotations.Benchmark; | ||
|
||
/** | ||
* A simple benchmark for calling an instance method of a user-defined class. | ||
*/ | ||
public class FibonacciBenchmark extends TruffleBenchmark { | ||
private static final String FIBONACCI_JS_FUNCTION = "" + | ||
"function fib(n) { " + | ||
" if (n > -2) { " + | ||
" return Math.abs(n); " + | ||
" } " + | ||
" return fib(n + 1) + fib(n + 2); " + | ||
"}"; | ||
private static final String FIBONACCI_JS_PROGRAM = FIBONACCI_JS_FUNCTION + "fib(-20);"; | ||
|
||
@Benchmark | ||
public int recursive_ezs_eval() { | ||
return this.truffleContext.eval("ezs", FIBONACCI_JS_PROGRAM).asInt(); | ||
} | ||
|
||
@Benchmark | ||
public int recursive_js_eval() { | ||
return this.truffleContext.eval("js", FIBONACCI_JS_PROGRAM).asInt(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters