Skip to content

Commit

Permalink
update perf tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender committed Nov 11, 2024
1 parent a6ea3d4 commit 4263cad
Showing 1 changed file with 13 additions and 64 deletions.
77 changes: 13 additions & 64 deletions tests/performance/Perf.BufferList.cs
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
namespace Performance;

// INCREMENTAL BUFFER-STYLE INDICATORS
// BUFFER-STYLE INCREMENTING INDICATORS

[ShortRunJob]
public class BufferLists
{
private static readonly IReadOnlyList<Quote> quotes
= Data.GetDefault();

private static readonly IReadOnlyList<IReusable> reusables
= quotes
.Cast<IReusable>()
.ToList();
private static readonly QuoteHub<Quote> provider = new();

private readonly QuoteHub<Quote> provider = new();
private const int n = 14;

[GlobalSetup]
public void Setup() => provider.Add(quotes);
Expand All @@ -26,70 +23,22 @@ public void Cleanup()
}

[Benchmark]
public object EmaIncRusBatch()
{
EmaList sut = new(14) { reusables };
return sut;
}
public AdxList AdxBuffer()
=> new(n) { quotes };

[Benchmark]
public object EmaIncRusItem()
{
EmaList sut = new(14);

for (int i = 0; i < reusables.Count; i++)
{
sut.Add(reusables[i]);
}

return sut;
}
public IReadOnlyList<AdxResult> AdxSeries()
=> quotes.ToAdx(n);

[Benchmark]
public object EmaIncRusSplit()
{
EmaList sut = new(14);

for (int i = 0; i < reusables.Count; i++)
{
sut.Add(reusables[i].Timestamp, reusables[i].Value);
}

return sut;
}
public EmaList EmaBuffer()
=> new(n) { quotes };

[Benchmark]
public object EmaIncQotBatch()
{
EmaList sut = new(14) { quotes };
return sut;
}

[Benchmark]
public object EmaIncQot()
{
EmaList sut = new(14);

for (int i = 0; i < quotes.Count; i++)
{
sut.Add(quotes[i]);
}

return sut;
}

// TIME-SERIES EQUIVALENTS

[Benchmark]
public object EmaSeries() => quotes.ToEma(14);

[Benchmark]
public object EmaIncrem()
{
EmaList ema = new(14) { quotes };
return ema;
}
public IReadOnlyList<EmaResult> EmaSeries()
=> quotes.ToEma(n);

[Benchmark]
public object EmaStream() => provider.ToEma(14).Results;
public IReadOnlyList<EmaResult> EmaStream()
=> provider.ToEma(n).Results;
}

0 comments on commit 4263cad

Please sign in to comment.