# Java sorting benchmarks ### How to use: ```bash mvn clean install java -jar target/sorting-benchmark.jar #default behavior -wi 20 -i 20 -f 10 java -jar -Darray.size=20000 target/sorting-benchmark.jar -wi 5 -i 5 -f 1 ``` ### Sample results ``` Benchmark Mode Cnt Score Error Units SortingBenchmark.bubbleSort avgt 14.059 s/op SortingBenchmark.insertionSort avgt 5.311 s/op SortingBenchmark.javaDefaultSort avgt 0.006 s/op SortingBenchmark.mergeSort avgt 0.009 s/op SortingBenchmark.quickSort avgt 0.008 s/op SortingBenchmark.selectionSort avgt 1.730 s/op ``` ### `jmh` command line options ```bash $ java -jar target/benchmarks.jar -h Usage: java -jar ... [regexp*] [options] [opt] means optional argument. means required argument. "+" means comma-separated list of values. "time" arguments accept time suffixes, like "100ms". [arguments] Benchmarks to run (regexp+). -bm Benchmark mode. Available modes are: [Throughput/thrpt, AverageTime/avgt, SampleTime/sample, SingleShotTime/ss, All/all] -bs Batch size: number of benchmark method calls per operation. Some benchmark modes may ignore this setting, please check this separately. -e Benchmarks to exclude from the run. -f How many times to fork a single benchmark. Use 0 to disable forking altogether. Warning: disabling forking may have detrimental impact on benchmark and infrastructure reliability, you might want to use different warmup mode instead. -foe Should JMH fail immediately if any benchmark had experienced an unrecoverable error? This helps to make quick sanity tests for benchmark suites, as well as make the automated runs with checking error codes. -gc Should JMH force GC between iterations? Forcing the GC may help to lower the noise in GC-heavy benchmarks, at the expense of jeopardizing GC ergonomics decisions. Use with care. -h Display help. -i Number of measurement iterations to do. Measurement iterations are counted towards the benchmark score. -jvm Use given JVM for runs. This option only affects forked runs. -jvmArgs Use given JVM arguments. Most options are inherited from the host VM options, but in some cases you want to pass the options only to a forked VM. Either single space-separated option line, or multiple options are accepted. This option only affects forked runs. -jvmArgsAppend Same as jvmArgs, but append these options before the already given JVM args. -jvmArgsPrepend Same as jvmArgs, but prepend these options before the already given JVM arg. -l List the benchmarks that match a filter, and exit. -lp List the benchmarks that match a filter, along with parameters, and exit. -lprof List profilers. -lrf List machine-readable result formats. -o Redirect human-readable output to a given file. -opi Override operations per invocation, see @OperationsPerInvocation Javadoc for details. -p Benchmark parameters. This option is expected to be used once per parameter. Parameter name and parameter values should be separated with equals sign. Parameter values should be separated with commas. -prof Use profilers to collect additional benchmark data. Some profilers are not available on all JVMs and/or all OSes. Please see the list of available profilers with -lprof. -r