https://github.com/consol/jcon-2019-democode-graalvm
https://github.com/consol/jcon-2019-democode-graalvm
Last synced: 4 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/consol/jcon-2019-democode-graalvm
- Owner: ConSol
- Created: 2019-09-23T12:47:06.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-09-25T07:38:18.000Z (over 6 years ago)
- Last Synced: 2024-12-31T05:28:57.465Z (over 1 year ago)
- Language: Java
- Size: 18.1 MB
- Stars: 2
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
This module provides a testing playground for the GraalVM.
In submodule `benchmarks`, some benchmarks are implemented. Note that the
`resources` folder contains some c-bitcode / javascript / python files, which
are then used by Graal's to run from java. Each benchmark is implemented as
standalone function (e.g. in `fibonacci.iterative.js`) and wrapped to execute
directly in javascript (e.g. in `fibonacci.iterative.starter.js`). The
computation code, however, is in both implementations exactly the same.
Submodule `jmh` wraps each benchmark in a JMH test. Tests are executed with the
`SingleShotTime` strategy. Each test consists of 10 warmup iterations and 10
test iterations. Results are reported in Seconds.
In submodule `native`, for each benchmark a executable class with some `public
static void main(String... args)` is created. This mimics the behaviour of the
JMH test from the `jmh` submodule. Folder `scripts` holds a file
`nativeScript.sh` to compile one native image per benchmark. For this to work,
it is necessary to export the environment variable `GRAALVM_HOME` to some
existing GraalVM. the native images are created within the `target` folder.
## Compile
In order to compile and package the project, `JAVA_HOME` must be set to a valid
GraalVM root dir with javascript-, llvm- and python-support enabled. Compile and
package the project by executing
> mvn clean package
## JMH Test
To execute tests, just execute
java -jar dus.graal.jmh-1.0-SNAPSHOT.jar
If you want to runs only a subset of tests, you can provide a regex matcher as
command line argument. For example, if you only with to execute fibonacci-tests,
run
java -jar dus.graal.jmh-1.0-SNAPSHOT.jar "Fibonacci
## JavaScript- and Python test
To execute the JavaScript- and Python-sources within an `js` or `python` parser
respectively, go to the corresponding folder:
* for `js`: `benchmark/src/main/resources/js/`
* for `python`: `benchmark/src/main/resources/python`
Execute the test by running the `*starter*`-file(s), e.g.:
> js fibonacci.recursive.starter.js
benchmark parameters for `js`-files are hard-coded within the file. For `python`,
the benchmark parameter can pe passed as first command line argument, e.g.:
> python fibonacci_recursive_starter.py 40
## C tests
In order to execute C code through Graal, we need to compile the code to
bitcode. Some C/C++ compilers support compilation to bitcode, e.g.
[`clang`][clang].
## Native Image build
To create the native images, `GRAALVM_HOME` must point to a valid Graal
installation directory. Build the native images by executing
> native/scripts/nativeCompile.sh
You will find the native images in folder `native/target`. Native image
compilation is not added to the maven build process on purpose since it takes
quite some time.
## Contact Information
If you have questions or would like to contribute, contact me via
marco(dot)bungart(at)consol(dot)de
or Twitter.
[clang]: https://clang.llvm.org/