Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
stevejgordon committed Nov 7, 2023
1 parent c364e39 commit 58e99f9
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,17 +93,24 @@ public void GetSamplesOptimised()
}
}

// WINDOWS:
//| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
//|-------------------- |---------:|--------:|---------:|---------:|--------:|-------:|----------:|------------:|
//| GetSamplesOriginal | 433.0 us | 8.39 us | 11.20 us | baseline | | 1.9531 | 29.4 KB | |
//| GetSamplesOptimised | 409.9 us | 5.11 us | 4.53 us | -5% | 3.0% | - | 1.47 KB | -95% |

// Yield return
// WINDOWS: After yield return
//| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Allocated | Alloc Ratio |
//|-------------------- |---------:|--------:|---------:|---------:|--------:|-------:|----------:|------------:|
//| GetSamplesOriginal | 429.1 us | 8.08 us | 13.93 us | baseline | | 1.9531 | 29.44 KB | |
//| GetSamplesOptimised | 419.7 us | 6.83 us | 6.39 us | -5% | 3.3% | - | 1.46 KB | -95% |

// LINUX: After yield return
//| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Allocated | Alloc Ratio |
//|-------------------- |---------:|----------:|----------:|---------:|--------:|-------:|-------:|----------:|------------:|
//| GetSamplesOriginal | 9.643 us | 0.1600 us | 0.1418 us | baseline | | 2.3346 | 0.0610 | 29328 B | |
//| GetSamplesOptimised | 5.525 us | 0.0580 us | 0.0569 us | -43% | 1.6% | 0.0534 | - | 680 B | -98% |

// Optimised
//| Method | Mean | Error | StdDev | Allocated |
//|----------- |---------:|--------:|--------:|----------:|
Expand Down
52 changes: 14 additions & 38 deletions benchmarks/Elastic.Apm.Profiling/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,66 +5,42 @@
using static Elastic.Apm.Metrics.MetricsProvider.CgroupMetricsProvider;
using Elastic.Apm.Logging;

//await DotMemory.EnsurePrerequisiteAsync();
await DotMemory.EnsurePrerequisiteAsync();
var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "dotTrace");
Console.WriteLine($"Saving to {path}");

var paths = CreateDefaultGroupFiles();

//var config = new DotMemory.Config();
//config.SaveToDir("C:\\Users\\SteveGordon\\Code\\Profiles");

//DotMemory.Attach(config);
var config = new DotMemory.Config();
config.SaveToDir(path);

//DotMemory.GetSnapshot("Before create");

//Console.ReadKey();
var paths = CreateDefaultGroupFiles();

// WARMUP
var sut = TestableCgroupMetricsProvider(new NoopLogger(), new List<WildcardMatcher>(), paths.RootPath, true);

Console.WriteLine("Snapshot");
Console.ReadKey();

Thread.Sleep(5000);

sut = TestableCgroupMetricsProvider(new NoopLogger(), new List<WildcardMatcher>(), paths.RootPath, true);

Thread.Sleep(3000);

Console.WriteLine("Snapshot");
Console.ReadKey();

//DotMemory.GetSnapshot("After create");

foreach (var metricSet in sut.GetSamples())
foreach (var _ in metricSet.Samples)
{
}

Console.WriteLine("Snapshot");
Console.ReadKey();
DotMemory.Attach(config);
DotMemory.GetSnapshot("Before create");

sut = TestableCgroupMetricsProvider(new NoopLogger(), new List<WildcardMatcher>(), paths.RootPath, true);

Thread.Sleep(5000);
DotMemory.GetSnapshot("After create");

foreach (var metricSet in sut.GetSamples())
foreach (var _ in metricSet.Samples)
{
}

Thread.Sleep(3000);
DotMemory.GetSnapshot("After get samples");

Console.WriteLine("Snapshot");
Console.ReadKey();

//DotMemory.GetSnapshot("After get samples");

//DotMemory.Detach();

//Console.ReadKey();
DotMemory.Detach();

Directory.Delete(paths.RootPath, true);

internal sealed class NoopLogger : IApmLogger
{
public bool IsEnabled(LogLevel level) => false;

public void Log<TState>(LogLevel level, TState state, Exception e, Func<TState, Exception, string> formatter) { }
}

0 comments on commit 58e99f9

Please sign in to comment.