This repository has been archived by the owner on Jan 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* migrated to NBench 1.2.1 to help resolve #4 * enabled NBench in FAKE build * added Span serialization spec
- Loading branch information
1 parent
21ff3a6
commit 88b0ece
Showing
6 changed files
with
99 additions
and
56 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 |
---|---|---|
|
@@ -46,6 +46,7 @@ _site/ | |
|
||
# MSTest test Results | ||
[Tt]est[Rr]esult*/ | ||
[Pp]erf[Rr]esult*/ | ||
[Bb]uild[Ll]og.* | ||
|
||
# NUNIT | ||
|
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
57 changes: 57 additions & 0 deletions
57
src/Petabridge.Tracing.Zipkin.Tests.Performance/SpanSerializerSpecs.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,57 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using NBench; | ||
using Petabridge.Tracing.Zipkin.Reporting; | ||
using Petabridge.Tracing.Zipkin.Tracers; | ||
|
||
namespace Petabridge.Tracing.Zipkin.Tests.Performance | ||
{ | ||
public class SpanSerializerSpecs | ||
{ | ||
public const string CounterName = "SerializedSpans"; | ||
|
||
public const int SpanCount = 100000; | ||
|
||
private readonly MockZipkinTracer _mockTracer = new MockZipkinTracer(new Endpoint("actorsystem", "127.0.0.1", 8008)); | ||
private readonly ISpanSerializer _serializer = new JsonSpanSerializer(); | ||
private Span _testSpan; | ||
private Counter _opsCounter; | ||
|
||
[PerfSetup] | ||
public void Setup(BenchmarkContext context) | ||
{ | ||
_opsCounter = context.GetCounter(CounterName); | ||
|
||
var startTime = new DateTimeOffset(new DateTime(2018, 1, 12, 13, 12, 14)); | ||
var endTime = startTime.AddMilliseconds(10); | ||
|
||
// create a reasonably complex span | ||
var span = new Span(_mockTracer, "op1", | ||
new SpanContext(new TraceId(7776525154056436086, 6707114971141086261), -7118946577185884628, null, | ||
true), | ||
startTime, SpanKind.CLIENT) | ||
.SetRemoteEndpoint(new Endpoint("actorsystem", "127.0.0.1", 8009)).SetTag("foo1", "bar") | ||
.SetTag("numberOfPets", 2) | ||
.SetTag("timeInChair", "long").Log(startTime.AddMilliseconds(1), "foo"); | ||
_testSpan = (Span) span; | ||
_testSpan.Finish(endTime); | ||
} | ||
|
||
[PerfBenchmark(NumberOfIterations = 5, RunMode = RunMode.Iterations, RunTimeMilliseconds = 1000)] | ||
[CounterMeasurement(CounterName)] | ||
[GcMeasurement(GcMetric.TotalCollections, GcGeneration.AllGc)] | ||
[MemoryMeasurement(MemoryMetric.TotalBytesAllocated)] | ||
public void SerializeSpans() | ||
{ | ||
for (var i = 0; i < SpanCount; i++) | ||
using(var mem = new MemoryStream()) | ||
_serializer.Serialize(mem, _testSpan); | ||
|
||
_opsCounter.Increment(SpanCount); | ||
} | ||
} | ||
} |