{"id":30612638,"url":"https://github.com/evolvedbinary/jni-benchmarks","last_synced_at":"2025-09-14T06:28:52.514Z","repository":{"id":42637339,"uuid":"49827098","full_name":"evolvedbinary/jni-benchmarks","owner":"evolvedbinary","description":"Benchmarks to compare various approaches for common JNI use-cases","archived":false,"fork":false,"pushed_at":"2024-07-26T16:16:02.000Z","size":8532,"stargazers_count":51,"open_issues_count":0,"forks_count":6,"subscribers_count":7,"default_branch":"main","last_synced_at":"2024-07-27T17:45:02.931Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/evolvedbinary.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-01-17T17:12:38.000Z","updated_at":"2024-07-26T16:16:04.000Z","dependencies_parsed_at":"2024-07-26T17:27:09.922Z","dependency_job_id":null,"html_url":"https://github.com/evolvedbinary/jni-benchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/evolvedbinary/jni-benchmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Fjni-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Fjni-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Fjni-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Fjni-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evolvedbinary","download_url":"https://codeload.github.com/evolvedbinary/jni-benchmarks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evolvedbinary%2Fjni-benchmarks/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272808936,"owners_count":24996603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-30T02:00:09.474Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-08-30T05:34:45.749Z","updated_at":"2025-08-30T05:34:46.391Z","avatar_url":"https://github.com/evolvedbinary.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JNI Benchmarks\n\n[![Build Status](https://dl.circleci.com/status-badge/img/gh/evolvedbinary/jni-benchmarks/tree/main.svg?style=svg)](https://dl.circleci.com/status-badge/redirect/gh/evolvedbinary/jni-benchmarks/tree/main)\n[![License](https://img.shields.io/badge/license-BSD%203-blue.svg)](https://opensource.org/licenses/BSD-3-Clause)\n\nWe provide the code for a small set of benchmarks to compare various approaches\nto solving common JNI use-cases and then present the results.\n\nThe benchmarks at present are:\n\n1. [com.evolvedbinary.jnibench.common.call](tree/main/src/main/java/com/evolvedbinary/jnibench/common/call) -\n  Benchmarks for [Creating Objects with JNI](ObjectCreationBenchmarks.md)\n  [(results)](ObjectCreationBenchmarks.md#object-creation-results).\n\n2. [com.evolvedbinary.jnibench.common.array](tree/main/src/main/java/com/evolvedbinary/jnibench/common/array) -\n  Benchmarks for [Passing Arrays with JNI](ArrayPassingBenchmarks.md)\n  [(results)](ArrayPassingBenchmarks.md#array-passing-results).\n\n3. [com.evolvedbinary.jnibench.common.bytearray](tree/main/src/main/java/com/evolvedbinary/jnibench/common/bytearray), and [com.evolvedbinary.jnibench.common.getputjni](tree/main/src/main/java/com/evolvedbinary/jnibench/common/getputjni) - Benchmarks for [JNI Data Transfer](DataBenchmarks.md).\n\n# Reproducing\n\nIf you want to run the code yourself, you need to have Java 8, Maven 3, and a\nC++ compiler that supports the C++ 11 standard. You can then simply run:\n\n```bash\n$ mvn clean compile package\n```\n\nIn the `target/` sub-directory, you will then find both a\n`jni-benchmarks-1.0.0-SNAPSHOT-application` folder and a\n`jni-benchmarks-1.0.0-SNAPSHOT-application.zip` file, you can use either of\nthese. They both contain bash scripts in their `bin/` sub-folders for Mac,\nLinux, Unix and batch scripts for Windows. These scripts will run a single\niteration of the benchmark.\n\nIf you want to run multiple iterations and get a CSV file of the results, you\ncan use `benchmark-100.sh` and/or `benchmark-100-with-close.sh`, or\n`array-benchmark-100.sh`.\n\n## JMH support\n\nWe have support for running the tests via JMH, see `jmh-benchmarks.sh`. You can\nalso pass `--help` to the script to see JMH options.\n\n### Byte array benchmarks\n\nThere are two benchmarks, which are currently available only via JMH:\nByteArrayFromNativeBenchmark and ByteArrayToNativeBenchmark. They can be run\nmultiple times using `jmh-benchmarks-parametrized.sh` with:\n\n```bash\n./jmh-benchmarks-parametrized.sh -i 10 -b ByteArrayToNativeBenchmark -o results/ -f csv\n```\n\nThe above command will run JMH with `ByteArrayToNativeBenchmark` benchmarks `10` times and store result in CSV files in `results` directory. You can also pass `--help` to the script to see additional JMH options that can be used.\n\nResults can then be plotted using the `process_byte_array_benchmarks_results.py` script. For example, to produce results for the `ByteArrayToNativeBenchmark` benchmarks, you can run:\n```bash\npython3 process_byte_array_benchmarks_results.py -p results/ --param-name \"Param: keySize\" --chart-title \"Performance comparison of passing byte array with {} bytes via JNI\"\n```\n\nCommand line parameter `p` expects a path to the directory with the JMH result CSV files from running the benchmarks with `jmh-benchmarks-parametrized.sh`.\nThe `{}` in the `chart-title` parameter will be replaced by the value from the `param-name` column.\n\n# Other Resources\n1. Java Foreign Interface prototype and performance results in RocksJava (i.e. Panama) - https://rocksdb.org/blog/2024/02/20/foreign-function-interface.html\n2. RocksJava API Performance Improvements - https://rocksdb.org/blog/2023/11/06/java-jni-benchmarks.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedbinary%2Fjni-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevolvedbinary%2Fjni-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevolvedbinary%2Fjni-benchmarks/lists"}