<commit_before>package io.jenetics.internal.math;

import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

@Fork(value = 1, warmups = 3)
@Warmup(iterations = 2)
@BenchmarkMode(Mode.AverageTime)
@Measurement(iterations = 5)
@OutputTimeUnit(TimeUnit.MICROSECONDS)
public class CombinatoricsPerf {

	@State(Scope.Benchmark)
	public static class BenchmarkState {

		@Param({
			"50/1",
			"50/2",
			"50/3",
			"50/5",
			"50/10",
			"50/15",
			"50/20",
			"50/25",
			"50/30",
			"50/35",
			"50/40",
			"50/45",
			"50/49",
		})
		public String nk;

		public int n;
		public int k;

		@Setup(Level.Trial)
		public void setUp() {
			final var split = nk.split("/");
			n = Integer.parseInt(split[0]);
			k = Integer.parseInt(split[1]);
		}
	}

	@Benchmark
	public int[] subset(final BenchmarkState state) {
		return Combinatorics.subset(state.n, state.k);
	}

}

/*
Benchmark                  (nk)   Mode  Cnt   Score   Error   Units<commit_msg>#798: Additional JMH subset tests.<commit_after>package io.jenetics.internal.math;

import java.util.concurrent.TimeUnit;

import org.openjdk.jmh.annotations.Benchmark;
import org.openjdk.jmh.annotations.BenchmarkMode;
import org.openjdk.jmh.annotations.Fork;
import org.openjdk.jmh.annotations.Level;
import org.openjdk.jmh.annotations.Measurement;
import org.openjdk.jmh.annotations.Mode;
import org.openjdk.jmh.annotations.OutputTimeUnit;
import org.openjdk.jmh.annotations.Param;
import org.openjdk.jmh.annotations.Scope;
import org.openjdk.jmh.annotations.Setup;
import org.openjdk.jmh.annotations.State;
import org.openjdk.jmh.annotations.Warmup;

@Fork(value = 1, warmups = 3)
@Warmup(iterations = 3)
@BenchmarkMode(Mode.AverageTime)
@Measurement(iterations = 5)
@OutputTimeUnit(TimeUnit.NANOSECONDS)
public class CombinatoricsPerf {

	@State(Scope.Benchmark)
	public static class BenchmarkState {

		@Param({
			"50/1",
			"50/2",
			"50/3",
			"50/4",
			"50/6",
			"50/8",
			"50/10",
			"50/12",
			"50/14",
			"50/16",
			"50/18",
			"50/20",
			"50/22",
			"50/24",
			"50/26",
			"50/28",
			"50/30",
			"50/32",
			"50/34",
			"50/36",
			"50/38",
			"50/40",
			"50/42",
			"50/44",
			"50/46",
			"50/48",
			"50/49",
		})
		public String nk;

		public int n;
		public int k;

		@Setup(Level.Trial)
		public void setUp() {
			final var split = nk.split("/");
			n = Integer.parseInt(split[0]);
			k = Integer.parseInt(split[1]);
		}
	}

	@Benchmark
	public int[] subset(final BenchmarkState state) {
		return Combinatorics.subset(state.n, state.k);
	}

}

/*
Benchmark                  (nk)  Mode  Cnt     Score     Error  Units
CombinatoricsPerf.subset   50/1  avgt    5    77.463 ±   1.074  ns/op
CombinatoricsPerf.subset   50/2  avgt    5   117.074 ±   3.234  ns/op
CombinatoricsPerf.subset   50/3  avgt    5   172.015 ±   2.781  ns/op
CombinatoricsPerf.subset   50/4  avgt    5   238.575 ±  12.577  ns/op
CombinatoricsPerf.subset   50/6  avgt    5   368.074 ±  11.813  ns/op
CombinatoricsPerf.subset   50/8  avgt    5   486.440 ±   8.302  ns/op
CombinatoricsPerf.subset  50/10  avgt    5   616.736 ±  28.068  ns/op
CombinatoricsPerf.subset  50/12  avgt    5   735.692 ±  11.639  ns/op
CombinatoricsPerf.subset  50/14  avgt    5   883.986 ±  21.073  ns/op
CombinatoricsPerf.subset  50/16  avgt    5  1013.184 ±  29.040  ns/op
CombinatoricsPerf.subset  50/18  avgt    5  1272.428 ±  37.367  ns/op
CombinatoricsPerf.subset  50/20  avgt    5  1430.692 ±  37.085  ns/op
CombinatoricsPerf.subset  50/22  avgt    5  1596.892 ±  68.767  ns/op
CombinatoricsPerf.subset  50/24  avgt    5  1671.377 ±  43.393  ns/op
CombinatoricsPerf.subset  50/26  avgt    5  1876.788 ±  45.864  ns/op
CombinatoricsPerf.subset  50/28  avgt    5  1991.426 ±  44.862  ns/op
CombinatoricsPerf.subset  50/30  avgt    5  2079.981 ±  42.206  ns/op
CombinatoricsPerf.subset  50/32  avgt    5  2280.386 ±  28.103  ns/op
CombinatoricsPerf.subset  50/34  avgt    5  2501.318 ±  37.715  ns/op
CombinatoricsPerf.subset  50/36  avgt    5  2741.034 ±  69.267  ns/op
CombinatoricsPerf.subset  50/38  avgt    5  3023.644 ±  70.023  ns/op
CombinatoricsPerf.subset  50/40  avgt    5  3288.124 ± 203.196  ns/op
CombinatoricsPerf.subset  50/42  avgt    5  3455.089 ±  94.088  ns/op
CombinatoricsPerf.subset  50/44  avgt    5  3782.770 ± 120.549  ns/op
CombinatoricsPerf.subset  50/46  avgt    5  4027.589 ± 286.878  ns/op
CombinatoricsPerf.subset  50/48  avgt    5  4874.910 ± 475.295  ns/op
CombinatoricsPerf.subset  50/49  avgt    5  5174.455 ± 319.814  ns/op
 */

/*
Benchmark                  (nk)   Mode  Cnt   Score   Error   Units
{'fraction_non_alphanumeric': 0.12726913970007891, 'fraction_numerical': 0.12016574585635359, 'mean_word_length': 2.9022324865280984, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6203816', 'n_tokens_mistral': 2582, 'n_tokens_neox': 2105, 'n_words': 434}