Closed Saibamen closed 10 months ago
Benchmark:
BenchmarkDotNet v0.13.12, Windows 10 (10.0.19045.3996/22H2/2022Update) Intel Core i7-7820HQ CPU 2.90GHz (Kaby Lake), 1 CPU, 8 logical and 4 physical cores .NET SDK 8.0.101 [Host] : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 .NET 6.0 : .NET 6.0.26 (6.0.2623.60508), X64 RyuJIT AVX2 .NET 8.0 : .NET 8.0.1 (8.0.123.58001), X64 RyuJIT AVX2 .NET Framework 4.8.1 : .NET Framework 4.8.1 (4.8.9195.0), X64 RyuJIT VectorSize=256
Nice!!!
Benchmark:
Code
```cs using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; namespace BenchmarkTemplate; [MemoryDiagnoser] [Config(typeof(StyleConfig))] [HideColumns("Job")] [SimpleJob(RuntimeMoniker.Net481)] [SimpleJob(RuntimeMoniker.Net60)] [SimpleJob(RuntimeMoniker.Net80)] public class CheckNumericOnlyBenchmarks { [Params("Numeric56Text", "NoNumericHere", "1633782928459")] public string Data; [Benchmark(Baseline = true)] public bool For() { char c; for (int i = 0; i < Data.Length; i++) { c = Data[i]; if (c < '0' && c > '9') { return false; } } return true; } [Benchmark] public bool Foreach() { foreach (var c in Data) { if (c < '0' && c > '9') { return false; } } return true; } } ```