-
Notifications
You must be signed in to change notification settings - Fork 451
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into trie-store-channels
- Loading branch information
Showing
199 changed files
with
2,130 additions
and
1,091 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
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
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
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
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
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
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
59 changes: 59 additions & 0 deletions
59
src/Nethermind/Nethermind.Benchmark/Core/ParallelBenchmark.cs
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,59 @@ | ||
// SPDX-FileCopyrightText: 2024 Demerzel Solutions Limited | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
using BenchmarkDotNet.Attributes; | ||
using Nethermind.Core.Threading; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace Nethermind.Benchmarks.Core; | ||
|
||
[HideColumns("Job", "RatioSD")] | ||
public class ParallelBenchmark | ||
{ | ||
private int[] _times; | ||
|
||
[GlobalSetup] | ||
public void Setup() | ||
{ | ||
_times = new int[200]; | ||
|
||
for (int i = 0; i < _times.Length; i++) | ||
{ | ||
_times[i] = i % 100; | ||
} | ||
} | ||
|
||
[Benchmark(Baseline = true)] | ||
public void ParallelFor() | ||
{ | ||
Parallel.For( | ||
0, | ||
_times.Length, | ||
(i) => Thread.Sleep(_times[i])); | ||
} | ||
|
||
[Benchmark] | ||
public void ParallelForEach() | ||
{ | ||
Parallel.ForEach( | ||
_times, | ||
(time) => Thread.Sleep(time)); | ||
} | ||
|
||
[Benchmark] | ||
public void UnbalancedParallel() | ||
{ | ||
ParallelUnbalancedWork.For<int[]>( | ||
0, | ||
_times.Length, | ||
ParallelUnbalancedWork.DefaultOptions, | ||
_times, | ||
(i, value) => | ||
{ | ||
Thread.Sleep(value[i]); | ||
return value; | ||
}, | ||
(value) => { }); | ||
} | ||
} |
Oops, something went wrong.