{"id":28963792,"url":"https://github.com/crowdcode-de/java-benchmarks","last_synced_at":"2025-06-24T04:12:39.368Z","repository":{"id":142394310,"uuid":"210125195","full_name":"crowdcode-de/java-benchmarks","owner":"crowdcode-de","description":"A Collection Of Java JMH Benchmarks","archived":false,"fork":false,"pushed_at":"2023-12-03T23:43:09.000Z","size":28,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-03-26T12:20:13.741Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.crowdcode.io","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/crowdcode-de.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}},"created_at":"2019-09-22T09:57:33.000Z","updated_at":"2024-03-26T12:20:13.741Z","dependencies_parsed_at":"2023-12-04T00:35:08.223Z","dependency_job_id":null,"html_url":"https://github.com/crowdcode-de/java-benchmarks","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/crowdcode-de/java-benchmarks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdcode-de%2Fjava-benchmarks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdcode-de%2Fjava-benchmarks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdcode-de%2Fjava-benchmarks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdcode-de%2Fjava-benchmarks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/crowdcode-de","download_url":"https://codeload.github.com/crowdcode-de/java-benchmarks/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/crowdcode-de%2Fjava-benchmarks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261601532,"owners_count":23183099,"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","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-06-24T04:12:38.374Z","updated_at":"2025-06-24T04:12:39.341Z","avatar_url":"https://github.com/crowdcode-de.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Java Micro-Benchmarks With JMH\n\n[![Build Status](https://travis-ci.org/crowdcode-de/java-benchmark.svg?branch=master)](https://travis-ci.org/crowdcode-de/java-benchmark)\n\nThese benchmarks are build with [OpenJDK JMH](https://openjdk.java.net/projects/code-tools/jmh/).\n\nJust another collection of typical Java Code Benchmarks.\n\n### How To Run The Benchmarks\n\nBuild the project `mvn clean install`.\n \nYou can call `java -jar target/benchmarks.jar -help` to see available command line parameters.\n\nFor instance, \n```\n  java -Xmx1G -jar targget/benchmarks.jar -f 1 -r 5 -i -wi 5 EmptyBenchmark\n```\n\n### Create Your Own Benchmark\n\n```\nmvn archetype:generate           \n       -DinteractiveMode=false           \n       -DarchetypeGroupId=org.openjdk.jmh          \n       -DarchetypeArtifactId=jmh-java-benchmark-archetype\n       -DarchetypeVersion=1.21           \n       -DgroupId=org.sample           \n       -DartifactId=test           \n       -Dversion=1.0-SNAPSHOT\n```\n\n## Benchmark Results\n\nREMEMBER: The numbers below are just data. To gain reusable insights, you need to follow up on\nwhy the numbers are the way they are. Use profilers (see -prof, -lprof), design factorial\nexperiments, perform baseline and negative tests that provide experimental control, make sure\nthe benchmarking environment is safe on JVM/OS/HW level, ask for reviews from the domain experts.\nDo not assume the numbers tell you what you want them to tell.\n\n### Use Multiply Instead Of Divide \n\nCheck `MultiplyVsDivisionBenchmark` to see that it is faster to multiply than to divide doubles.\n\n```\n    double divisor = 10.0;\n    double a = a / divisor // repeat this 1_000 times\n    ...\n```\n\nbetter use\n\n```\n    double divisor = 10.0;\n    double factor = 1 / divisor;\n    double a = nextDouble() * factor; // repeat this 1_000 times\n```\n\nResults with JDK 13:\n\n````\njava -Xmx1G -jar target/benchmarks.jar -f 1 -r 1 -i 5 -w 1 -wi 5 MultiplyVsDivisionBenchmark\n````\n\n|Benchmark                                             |  Mode |  Cnt |      Score |      Error | Units|\n|:-----------------------------------------------------|:-----:|:----:|:----------:|:----------:|:----:|\n|MultiplyVsDivisionBenchmark.divideDoubles             | thrpt |   5  | 207619,369 | ± 2662,392 | ops/s|\n|MultiplyVsDivisionBenchmark.divideDoublesWithMultiply | thrpt |   5  | 508495,675 | ± 8033,898 | ops/s|\n\n\n### Random Subset Without Duplicates\n \n`RandomSubsetBenchmark`\n\nResults with JDK 13:\n\n````\njava -Xmx1G -jar target/benchmarks.jar -f 1 -r 1 -i 5 -w 1 -wi 5 RandomSubsetBenchmark\n````\n\n|Benchmark                                             |  Mode |  Cnt |      Score |      Error | Units|\n|:-----------------------------------------------------|:-----:|:----:|:----------:|:----------:|:----:|\n|RandomSubsetBenchmark.subsetWithForLoop               | thrpt |   5|  1720,292 | ± 330,771 | ops/s|\n|RandomSubsetBenchmark.subsetWithParallelStreams       | thrpt |   5|   779,079 | ±  23,238 | ops/s|\n|RandomSubsetBenchmark.subsetWithStreams               | thrpt |   5|  1200,939 | ± 140,346 | ops/s|\n\n\n### Date Parsing And Adding An Hour Benchmark \n \n`DateBenchmark`\n\n\n````\njava -Xmx1G -jar target/benchmarks.jar -f 1 -r 1 -i 5 -w 1 -wi 5 DateBenchmark\n````\n\n|Benchmark                                             |  Mode |  Cnt |      Score |      Error | Units|\n|:-----------------------------------------------------|:-----:|:----:|:----------:|:----------:|:----:|\n|DateBenchmark.dateLong              | thrpt |   5 | 386571214,471 | ± 10171784,541 | ops/s|\n|DateBenchmark.dateLongWithFormat    | thrpt |   5 |   3358368,673 | ±    31265,425 | ops/s|\n|DateBenchmark.dateParsingWithFormat | thrpt |   5 |    728327,799 | ±    19937,432 | ops/s|\n|DateBenchmark.parsingLocalDateTime  | thrpt |   5 |    873308,951 | ±    97291,855 | ops/s|\n\n### Using Initial Capacity At ArrayList\n\nRun with JDK 12 and `java -jar target/benchmarks.jar -f 1 -r 2 -w 2 -wi 5 InitialCapacityBenchmark`\n\n|Benchmark                                                     |  Mode |  Cnt | Score |    Error | Units|\n|:-------------------------------------------------------------|:-----:|:----:|:-----:|:--------:|:----:|\n|InitialCapacityBenchmark.addWithInitialCapacity               | thrpt |   5 | 29,552 | ± 13,596 | ops/s|\n|InitialCapacityBenchmark.addWithInitialCapacityWithStreams    | thrpt |   5 | 25,123 | ± 10,103 | ops/s|\n|InitialCapacityBenchmark.addWithoutInitialCapacity            | thrpt |   5 | 19,304 | ±  3,389 | ops/s|\n|InitialCapacityBenchmark.addWithoutInitialCapacityWithStreams | thrpt |   5 | 19,012 | ±  6,849 | ops/s|\n\n \n\n\n### Created By\n\n[CROWDCODE GmbH \u0026 Co. KG](https://www.crowdcode.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdcode-de%2Fjava-benchmarks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcrowdcode-de%2Fjava-benchmarks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcrowdcode-de%2Fjava-benchmarks/lists"}