-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5884595
commit 5ec3b14
Showing
7 changed files
with
82 additions
and
53 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
// ReSharper disable InconsistentlySynchronizedField | ||
namespace Pure.DI.Benchmarks; | ||
|
||
using System.Diagnostics.CodeAnalysis; | ||
using BenchmarkDotNet.Attributes; | ||
using Moq; | ||
|
||
[SuppressMessage("Performance", "CA1822:Пометьте члены как статические")] | ||
public class OwnedBenchmark | ||
{ | ||
private const int Count = 128; | ||
private static readonly IDisposable Disposable = Mock.Of<IDisposable>(); | ||
|
||
[Benchmark(Baseline = true)] | ||
public List<IDisposable> ListAdd() | ||
{ | ||
var list = new List<IDisposable>(); | ||
for (var i = 0; i < Count; i++) | ||
{ | ||
if (Disposable is IOwned) | ||
{ | ||
continue; | ||
} | ||
|
||
list.Add(Disposable); | ||
} | ||
|
||
return list; | ||
} | ||
|
||
[Benchmark] | ||
public IOwned OwnedAdd() | ||
{ | ||
var owned = new Owned(); | ||
for (var i = 0; i < Count; i++) | ||
{ | ||
owned.Add(Disposable); | ||
} | ||
|
||
return owned; | ||
} | ||
} |
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