-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Processing dotnet/runtime#112046 (comment) command:
Command
-amd -arm -profiler --envvars JitDisasm:InversionMutation
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Running;
public class Benchmarks
{
private const int Seed = 100;
private static readonly int[] Chromosome = new int[59];
private static readonly Random Random = new(Seed);
public Benchmarks()
{
var genes = Enumerable.Range(1, 59).ToArray();
Random.Shuffle(genes);
genes.CopyTo(Chromosome.AsSpan());
}
[Benchmark]
public int[] InversionMutation()
{
var idx1 = 0;
var idx2 = 0;
var chromosomeLength = Chromosome.Length;
while (idx1 == idx2)
{
idx1 = Random.Next(chromosomeLength);
idx2 = Random.Next(chromosomeLength);
}
if (idx1 > idx2)
{
(idx1, idx2) = (idx2, idx1);
}
Array.Reverse(Chromosome, idx1, idx2 - idx1 + 1);
return Chromosome;
}
}(EgorBot will reply in this issue)
Metadata
Metadata
Assignees
Labels
No labels