Skip to content

Commit

Permalink
- Removing number of iterations which isn't required for setting up a…
Browse files Browse the repository at this point in the history
… benchmark, since benchmark.net will automatically determine the number itself.

- All benchmarks will now be run by default when no arguments are passed.  The results from each benchmark will be combined into a single report for command line and HTML.  The report will now be automatically opened in the browser.
- Since all benchmarks are being run by default, removed AllBenchmarks.cs which isn't necessary anymore.
- Removed ProtobufSerializer.cs which is unused.
- Cleaned up usings.
  • Loading branch information
tpill90 committed Dec 5, 2024
1 parent 3d2ea7c commit 21b49d3
Show file tree
Hide file tree
Showing 8 changed files with 54 additions and 302 deletions.
200 changes: 0 additions & 200 deletions src/Benchmarks/ServiceWire.Benchmarks/AllBenchmarks.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using ServiceWire.NamedPipes;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
Expand All @@ -9,13 +7,11 @@

namespace ServiceWire.Benchmarks
{
[MinIterationCount(4)]
[MaxIterationCount(16)]
[InvocationCount(64)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
[HtmlExporter]
public class ConnectionBenchmarks
{
private INetTester _tester;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
using System;
using System.Linq;
using System.Threading.Tasks;
using ServiceWire.NamedPipes;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;

namespace ServiceWire.Benchmarks
{
[MinIterationCount(8)]
[MaxIterationCount(64)]
[InvocationCount(1024)]
[SimpleJob(RuntimeMoniker.Net80, baseline: true)]
[SimpleJob(RuntimeMoniker.Net60)]
[SimpleJob(RuntimeMoniker.Net48)]
[MemoryDiagnoser]
[HtmlExporter]
public class NamedPipesBenchmarks
{
private INetTester _tester;
Expand Down
5 changes: 0 additions & 5 deletions src/Benchmarks/ServiceWire.Benchmarks/NewtonSoftSerializer.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using ServiceWire;
using Newtonsoft.Json;

namespace ServiceWire.Benchmarks
Expand Down
57 changes: 50 additions & 7 deletions src/Benchmarks/ServiceWire.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,18 +1,61 @@
using BenchmarkDotNet.Running;
using System;
using System.Collections.Generic;
using System.Text;
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
using BenchmarkDotNet.Running;

namespace ServiceWire.Benchmarks
{
public class Program
{
public static void Main(string[] args)
{
//var summary = BenchmarkRunner.Run<NamedPipesBenchmarks>();
//summary = BenchmarkRunner.Run<TcpBenchmarks>();
// These can be helpful if you're just trying to work on a single benchmark
//BenchmarkRunner.Run<ConnectionBenchmarks>();
//BenchmarkRunner.Run<NamedPipesBenchmarks>();
//BenchmarkRunner.Run<TcpBenchmarks>();

var summary = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(args);

var switcher = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly);
// Run with command line args if provided
if (args.Length > 0)
{
switcher.Run(args);
return;
}

// Otherwise run them all and combine the results into a single report (command line, HTML)
var summary = switcher.RunAllJoined();

// Launching the html report in the browser, makes it nice and easy to see the results
string htmlReportPath = System.IO.Path.Combine(summary.ResultsDirectoryPath, $"{summary.Title}-report.html");
OpenUrl(htmlReportPath);
}


private static void OpenUrl(string url)
{
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
{
url = url.Replace("&", "^&");
Process.Start(new ProcessStartInfo(url) { UseShellExecute = true });
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
{
// Detects to see if the user is running in a "desktop environment"/GUI, or if they are running in a terminal session.
// Won't be able to launch a web browser without a GUI
// https://en.wikipedia.org/wiki/Desktop_environment
var currDesktopEnvironment = Environment.GetEnvironmentVariable("XDG_CURRENT_DESKTOP");
if (String.IsNullOrEmpty(currDesktopEnvironment))
{
return;
}

Process.Start("xdg-open", url);
}
else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
{
Process.Start("open", url);
}
}
}
}
74 changes: 0 additions & 74 deletions src/Benchmarks/ServiceWire.Benchmarks/ProtobufSerializer.cs

This file was deleted.

Loading

0 comments on commit 21b49d3

Please sign in to comment.