Processing dotnet/runtime#123434 (comment) command:
Command
-amd -intel
usingSystem.Runtime.CompilerServices;usingSystem.Text;usingBenchmarkDotNet.Attributes;usingBenchmarkDotNet.Running;BenchmarkSwitcher.FromAssembly(typeof(ContainsTrue).Assembly).Run(args);publicclassContainsTrue{privatestring[]_found;privatestring[]_array;privateList<string>_list;[Params(512)]publicintSize;[GlobalSetup(Targets=new[]{nameof(Array)})]publicvoidSetupArray(){_found=ArrayOfUniqueValues(Size);_array=_found.ToArray();}[Benchmark]publicboolArray(){boolresult=default;string[]collection=_array;string[]found=_found;for(inti=0;i<found.Length;i++)result^=collection.Contains(found[i]);returnresult;}[GlobalSetup(Targets=new[]{nameof(ICollection)})]publicvoidSetupList(){_found=ArrayOfUniqueValues(Size);_list=newList<string>(_found);}[Benchmark]publicboolICollection()=>Contains(_list);[MethodImpl(MethodImplOptions.NoInlining)]privateboolContains(ICollection<string>collection){boolresult=default;string[]found=_found;for(inti=0;i<found.Length;i++)result^=collection.Contains(found[i]);returnresult;}privatestaticstring[]ArrayOfUniqueValues(intcount){string[]result=newstring[count];varrandom=newRandom(42);varuniqueValues=newHashSet<string>();while(uniqueValues.Count!=count){stringvalue=GenerateRandomString(random,1,50);if(!uniqueValues.Contains(value))uniqueValues.Add(value);}uniqueValues.CopyTo(result);returnresult;}privatestaticstringGenerateRandomString(Randomrandom,intminLength,intmaxLength){varlength=random.Next(minLength,maxLength);varbuilder=newStringBuilder(length);for(inti=0;i<length;i++){varrangeSelector=random.Next(0,3);if(rangeSelector==0)builder.Append((char)random.Next('a','z'));elseif(rangeSelector==1)builder.Append((char)random.Next('A','Z'));elsebuilder.Append((char)random.Next('0','9'));}returnbuilder.ToString();}}(EgorBot will reply in this issue)
Processing dotnet/runtime#123434 (comment) command:
Command
-amd -intel
(EgorBot will reply in this issue)