-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--- This is an internal tool that allows you to benchmark various Nitrocid functions. Currently, it'll stay that way until the development of 0.1.1 starts. --- Type: add Breaking: False Doc Required: False Part: 1/1
- Loading branch information
Showing
17 changed files
with
679 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
namespace Nitrocid.Benchmarks | ||
{ | ||
public abstract class BenchFixture | ||
{ | ||
public virtual void Run() { } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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<IEncodingDriver>("Default"); | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Default"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
encoding.Initialize(); | ||
for (int i = 0; i < 1000000; i++) | ||
{ | ||
int num = random.Random(); | ||
encoding.GetEncodedString($"#{num}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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<IEncodingDriver>("RSA"); | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Default"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
encoding.Initialize(); | ||
for (int i = 0; i < 1000000; i++) | ||
{ | ||
int num = random.Random(); | ||
encoding.GetEncodedString($"#{num}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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<IEncryptionDriver>("SHA256"); | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Default"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
for (int i = 0; i < 1000000; i++) | ||
{ | ||
int num = random.Random(); | ||
encryption.GetEncryptedString($"#{num}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
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<IEncryptionDriver>("SHA512"); | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Default"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
for (int i = 0; i < 1000000; i++) | ||
{ | ||
int num = random.Random(); | ||
encryption.GetEncryptedString($"#{num}"); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Nitrocid.Drivers; | ||
using Nitrocid.Drivers.RNG; | ||
|
||
namespace Nitrocid.Benchmarks.Fixtures | ||
{ | ||
public class RngDefault : BenchFixture | ||
{ | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Default"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
for (int i = 0; i < 1000000; i++) | ||
random.Random(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <https://www.gnu.org/licenses/>. | ||
// | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Nitrocid.Drivers; | ||
using Nitrocid.Drivers.RNG; | ||
|
||
namespace Nitrocid.Benchmarks.Fixtures | ||
{ | ||
public class RngOptimized : BenchFixture | ||
{ | ||
private readonly IRandomDriver random = DriverHandler.GetDriver<IRandomDriver>("Optimized"); | ||
|
||
[Benchmark] | ||
public override void Run() | ||
{ | ||
for (int i = 0; i < 1000000; i++) | ||
random.Random(); | ||
} | ||
} | ||
} |
Oops, something went wrong.