diff --git a/Nitrocid.sln b/Nitrocid.sln index a9c2ecbac5..baf32b8742 100644 --- a/Nitrocid.sln +++ b/Nitrocid.sln @@ -170,6 +170,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nitrocid.Extras.Sha1", "pub EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Nitrocid.Extras.Sha384", "public\Nitrocid.Addons\Nitrocid.Extras.Sha384\Nitrocid.Extras.Sha384.csproj", "{600337A5-0D56-476A-9428-52B1EF665950}" EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Benchmarks", "Benchmarks", "{EA27625C-C2DE-4080-9253-A572114EDC21}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Nitrocid.Benchmarks", "private\Nitrocid.Benchmarks\Nitrocid.Benchmarks.csproj", "{32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -388,6 +392,10 @@ Global {600337A5-0D56-476A-9428-52B1EF665950}.Debug|Any CPU.Build.0 = Debug|Any CPU {600337A5-0D56-476A-9428-52B1EF665950}.Release|Any CPU.ActiveCfg = Release|Any CPU {600337A5-0D56-476A-9428-52B1EF665950}.Release|Any CPU.Build.0 = Release|Any CPU + {32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3}.Debug|Any CPU.Build.0 = Debug|Any CPU + {32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3}.Release|Any CPU.ActiveCfg = Release|Any CPU + {32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -451,6 +459,8 @@ Global {CE5F80A9-B27E-4D16-AEBB-A09677E63012} = {B60F276A-FE12-4001-916E-080344ED1FD9} {BB2BCBE2-1F15-4B5F-927F-172B4B7FE9D4} = {B60F276A-FE12-4001-916E-080344ED1FD9} {600337A5-0D56-476A-9428-52B1EF665950} = {B60F276A-FE12-4001-916E-080344ED1FD9} + {EA27625C-C2DE-4080-9253-A572114EDC21} = {61916ED1-66D6-4938-9F1A-D0DF38D16E20} + {32EFC1E5-CE9A-457D-BDC3-3EDE638DE5F3} = {EA27625C-C2DE-4080-9253-A572114EDC21} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {424D8E7A-CFEB-40AE-A79C-437D603177FD} diff --git a/private/Nitrocid.Benchmarks/BenchFixture.cs b/private/Nitrocid.Benchmarks/BenchFixture.cs new file mode 100644 index 0000000000..305bf8e663 --- /dev/null +++ b/private/Nitrocid.Benchmarks/BenchFixture.cs @@ -0,0 +1,26 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +namespace Nitrocid.Benchmarks +{ + public abstract class BenchFixture + { + public virtual void Run() { } + } +} diff --git a/private/Nitrocid.Benchmarks/Entry.cs b/private/Nitrocid.Benchmarks/Entry.cs new file mode 100644 index 0000000000..144a3ad9db --- /dev/null +++ b/private/Nitrocid.Benchmarks/Entry.cs @@ -0,0 +1,38 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using Nitrocid.ConsoleBase.Colors; +using Nitrocid.ConsoleBase.Writers; + +namespace Nitrocid.Benchmarks +{ + internal class Entry + { + static void Main(string[] args) + { + if (args.Length == 0) + { + TextWriters.Write("Specify a benchmark to run.", KernelColorType.Error); + return; + } + string benchName = args[0]; + FixtureManager.RunBenchmark(benchName); + } + } +} diff --git a/private/Nitrocid.Benchmarks/FixtureManager.cs b/private/Nitrocid.Benchmarks/FixtureManager.cs new file mode 100644 index 0000000000..e292a652d9 --- /dev/null +++ b/private/Nitrocid.Benchmarks/FixtureManager.cs @@ -0,0 +1,34 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Running; + +namespace Nitrocid.Benchmarks +{ + internal static class FixtureManager + { + internal static void RunBenchmark(string fixture) + { + // Get the benchmark fixture and run it + var fixtureType = Type.GetType($"Nitrocid.Benchmarks.Fixtures.{fixture}") ?? + throw new Exception($"No fixture type called {fixture}."); + BenchmarkRunner.Run(fixtureType); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/EncodingAes.cs b/private/Nitrocid.Benchmarks/Fixtures/EncodingAes.cs new file mode 100644 index 0000000000..1fdb21a9d9 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/EncodingAes.cs @@ -0,0 +1,43 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.Encoding; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class EncodingAes : BenchFixture + { + private readonly IEncodingDriver encoding = DriverHandler.GetDriver("Default"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Default"); + + [Benchmark] + public override void Run() + { + encoding.Initialize(); + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + encoding.GetEncodedString($"#{num}"); + } + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/EncodingRsa.cs b/private/Nitrocid.Benchmarks/Fixtures/EncodingRsa.cs new file mode 100644 index 0000000000..e03cdba1e7 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/EncodingRsa.cs @@ -0,0 +1,43 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.Encoding; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class EncodingRsa : BenchFixture + { + private readonly IEncodingDriver encoding = DriverHandler.GetDriver("RSA"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Default"); + + [Benchmark] + public override void Run() + { + encoding.Initialize(); + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + encoding.GetEncodedString($"#{num}"); + } + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha256.cs b/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha256.cs new file mode 100644 index 0000000000..67e865fdc2 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha256.cs @@ -0,0 +1,42 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.Encryption; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class EncryptionSha256 : BenchFixture + { + private readonly IEncryptionDriver encryption = DriverHandler.GetDriver("SHA256"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Default"); + + [Benchmark] + public override void Run() + { + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + encryption.GetEncryptedString($"#{num}"); + } + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha512.cs b/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha512.cs new file mode 100644 index 0000000000..def1666c73 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/EncryptionSha512.cs @@ -0,0 +1,42 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.Encryption; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class EncryptionSha512 : BenchFixture + { + private readonly IEncryptionDriver encryption = DriverHandler.GetDriver("SHA512"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Default"); + + [Benchmark] + public override void Run() + { + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + encryption.GetEncryptedString($"#{num}"); + } + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/RngDefault.cs b/private/Nitrocid.Benchmarks/Fixtures/RngDefault.cs new file mode 100644 index 0000000000..3fdc9172de --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/RngDefault.cs @@ -0,0 +1,37 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class RngDefault : BenchFixture + { + private readonly IRandomDriver random = DriverHandler.GetDriver("Default"); + + [Benchmark] + public override void Run() + { + for (int i = 0; i < 1000000; i++) + random.Random(); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/RngOptimized.cs b/private/Nitrocid.Benchmarks/Fixtures/RngOptimized.cs new file mode 100644 index 0000000000..5b26eaa179 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/RngOptimized.cs @@ -0,0 +1,37 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class RngOptimized : BenchFixture + { + private readonly IRandomDriver random = DriverHandler.GetDriver("Optimized"); + + [Benchmark] + public override void Run() + { + for (int i = 0; i < 1000000; i++) + random.Random(); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/RngStandard.cs b/private/Nitrocid.Benchmarks/Fixtures/RngStandard.cs new file mode 100644 index 0000000000..ba71c69c6a --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/RngStandard.cs @@ -0,0 +1,37 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class RngStandard : BenchFixture + { + private readonly IRandomDriver random = DriverHandler.GetDriver("Standard"); + + [Benchmark] + public override void Run() + { + for (int i = 0; i < 1000000; i++) + random.Random(); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/SortingDefault.cs b/private/Nitrocid.Benchmarks/Fixtures/SortingDefault.cs new file mode 100644 index 0000000000..3299b049e7 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/SortingDefault.cs @@ -0,0 +1,56 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; +using Nitrocid.Drivers.Sorting; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class SortingDefault : BenchFixture + { + private readonly ISortingDriver sort = DriverHandler.GetDriver("Default"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Standard"); + + [Benchmark] + public override void Run() + { + int[] array = new int[1000000]; + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + + [Benchmark] + public void RunHuge() + { + int[] array = new int[int.MaxValue]; + for (int i = 0; i < int.MaxValue; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/SortingMerge.cs b/private/Nitrocid.Benchmarks/Fixtures/SortingMerge.cs new file mode 100644 index 0000000000..5f4c7ffa1b --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/SortingMerge.cs @@ -0,0 +1,56 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; +using Nitrocid.Drivers.Sorting; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class SortingMerge : BenchFixture + { + private readonly ISortingDriver sort = DriverHandler.GetDriver("Merge"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Standard"); + + [Benchmark] + public override void Run() + { + int[] array = new int[1000000]; + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + + [Benchmark] + public void RunHuge() + { + int[] array = new int[int.MaxValue]; + for (int i = 0; i < int.MaxValue; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/SortingQuick.cs b/private/Nitrocid.Benchmarks/Fixtures/SortingQuick.cs new file mode 100644 index 0000000000..78098f4477 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/SortingQuick.cs @@ -0,0 +1,56 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; +using Nitrocid.Drivers.Sorting; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class SortingQuick : BenchFixture + { + private readonly ISortingDriver sort = DriverHandler.GetDriver("Quick"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Standard"); + + [Benchmark] + public override void Run() + { + int[] array = new int[1000000]; + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + + [Benchmark] + public void RunHuge() + { + int[] array = new int[int.MaxValue]; + for (int i = 0; i < int.MaxValue; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Fixtures/SortingSelection.cs b/private/Nitrocid.Benchmarks/Fixtures/SortingSelection.cs new file mode 100644 index 0000000000..e6ee9245a0 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Fixtures/SortingSelection.cs @@ -0,0 +1,56 @@ +// +// Nitrocid KS Copyright (C) 2018-2024 Aptivi +// +// This file is part of Nitrocid KS +// +// Nitrocid KS is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// Nitrocid KS is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY, without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +using BenchmarkDotNet.Attributes; +using Nitrocid.Drivers; +using Nitrocid.Drivers.RNG; +using Nitrocid.Drivers.Sorting; + +namespace Nitrocid.Benchmarks.Fixtures +{ + public class SortingSelection : BenchFixture + { + private readonly ISortingDriver sort = DriverHandler.GetDriver("Selection"); + private readonly IRandomDriver random = DriverHandler.GetDriver("Standard"); + + [Benchmark] + public override void Run() + { + int[] array = new int[1000000]; + for (int i = 0; i < 1000000; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + + [Benchmark] + public void RunHuge() + { + int[] array = new int[int.MaxValue]; + for (int i = 0; i < int.MaxValue; i++) + { + int num = random.Random(); + array[i] = num; + } + sort.SortNumbersInt32(array); + } + } +} diff --git a/private/Nitrocid.Benchmarks/Nitrocid.Benchmarks.csproj b/private/Nitrocid.Benchmarks/Nitrocid.Benchmarks.csproj new file mode 100644 index 0000000000..77040c1c8e --- /dev/null +++ b/private/Nitrocid.Benchmarks/Nitrocid.Benchmarks.csproj @@ -0,0 +1,18 @@ + + + + Exe + net8.0 + enable + enable + + + + + + + + + + + diff --git a/private/Nitrocid.Benchmarks/Properties/launchSettings.json b/private/Nitrocid.Benchmarks/Properties/launchSettings.json new file mode 100644 index 0000000000..9f0e963264 --- /dev/null +++ b/private/Nitrocid.Benchmarks/Properties/launchSettings.json @@ -0,0 +1,48 @@ +{ + "profiles": { + "Nitrocid.Benchmarks - EncodingAes": { + "commandName": "Project", + "commandLineArgs": "EncodingAes" + }, + "Nitrocid.Benchmarks - EncodingRsa": { + "commandName": "Project", + "commandLineArgs": "EncodingRsa" + }, + "Nitrocid.Benchmarks - EncryptionSha256": { + "commandName": "Project", + "commandLineArgs": "EncryptionSha256" + }, + "Nitrocid.Benchmarks - EncryptionSha512": { + "commandName": "Project", + "commandLineArgs": "EncryptionSha512" + }, + "Nitrocid.Benchmarks - RngDefault": { + "commandName": "Project", + "commandLineArgs": "RngDefault" + }, + "Nitrocid.Benchmarks - RngOptimized": { + "commandName": "Project", + "commandLineArgs": "RngOptimized" + }, + "Nitrocid.Benchmarks - RngStandard": { + "commandName": "Project", + "commandLineArgs": "RngStandard" + }, + "Nitrocid.Benchmarks - SortingDefault": { + "commandName": "Project", + "commandLineArgs": "SortingDefault" + }, + "Nitrocid.Benchmarks - SortingMerge": { + "commandName": "Project", + "commandLineArgs": "SortingMerge" + }, + "Nitrocid.Benchmarks - SortingQuick": { + "commandName": "Project", + "commandLineArgs": "SortingQuick" + }, + "Nitrocid.Benchmarks - SortingSelection": { + "commandName": "Project", + "commandLineArgs": "SortingSelection" + } + } +}