Skip to content

Commit

Permalink
[tests] Add a performance test using BenchmarkDotNet.
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfbjarne committed Apr 22, 2021
1 parent add11fb commit 5448fbe
Show file tree
Hide file tree
Showing 32 changed files with 1,657 additions and 0 deletions.
1 change: 1 addition & 0 deletions NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
<add key="dotnet6" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet6/nuget/v3/index.json" />
<add key="dotnet5" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet5/nuget/v3/index.json" />
<add key="xamarin-impl" value="https://pkgs.dev.azure.com/azure-public/vside/_packaging/xamarin-impl/nuget/v3/index.json" />
<add key="macios-dependencies" value="https://pkgs.dev.azure.com/xamarin/public/_packaging/macios-dependencies/nuget/v3/index.json" />
</packageSources>
<disabledPackageSources>
<clear />
Expand Down
19 changes: 19 additions & 0 deletions tests/bindings-test/ApiDefinition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,25 @@ partial interface ObjCRegistrarTest {
[Export ("V")]
void V ();

[Static]
[Export ("staticV")]
void StaticV ();

[Export ("getEmptyString")]
string GetEmptyString ();

[Export ("getShortString")]
string GetShortString ();

[Export ("getLongString")]
string GetLongString ();

[Export ("someObject")]
NSObject SomeObject { get; set; }

[Export ("someArray")]
NSObject[] SomeArray { get; set; }

[Export ("F")]
float F ();

Expand Down
2 changes: 2 additions & 0 deletions tests/perftest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
output

11 changes: 11 additions & 0 deletions tests/perftest/AppDelegate.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using AppKit;
using Foundation;

namespace MyCocoaApp {
[Register ("AppDelegate")]
public class AppDelegate : NSApplicationDelegate {
public AppDelegate ()
{
}
}
}
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
68 changes: 68 additions & 0 deletions tests/perftest/Assets.xcassets/AppIcon.appiconset/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
{
"images": [
{
"filename": "AppIcon-16.png",
"size": "16x16",
"scale": "1x",
"idiom": "mac"
},
{
"filename": "AppIcon-16@2x.png",
"size": "16x16",
"scale": "2x",
"idiom": "mac"
},
{
"filename": "AppIcon-32.png",
"size": "32x32",
"scale": "1x",
"idiom": "mac"
},
{
"filename": "AppIcon-32@2x.png",
"size": "32x32",
"scale": "2x",
"idiom": "mac"
},
{
"filename": "AppIcon-128.png",
"size": "128x128",
"scale": "1x",
"idiom": "mac"
},
{
"filename": "AppIcon-128@2x.png",
"size": "128x128",
"scale": "2x",
"idiom": "mac"
},
{
"filename": "AppIcon-256.png",
"size": "256x256",
"scale": "1x",
"idiom": "mac"
},
{
"filename": "AppIcon-256@2x.png",
"size": "256x256",
"scale": "2x",
"idiom": "mac"
},
{
"filename": "AppIcon-512.png",
"size": "512x512",
"scale": "1x",
"idiom": "mac"
},
{
"filename": "AppIcon-512@2x.png",
"size": "512x512",
"scale": "2x",
"idiom": "mac"
}
],
"info": {
"version": 1,
"author": "xcode"
}
}
6 changes: 6 additions & 0 deletions tests/perftest/Assets.xcassets/Contents.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
6 changes: 6 additions & 0 deletions tests/perftest/Entitlements.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
</dict>
</plist>
32 changes: 32 additions & 0 deletions tests/perftest/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleName</key>
<string>MyCocoaApp</string>
<key>CFBundleIdentifier</key>
<string>com.xamarin.MyCocoaApp</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>10.15</string>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>NSHumanReadableCopyright</key>
<string>${AuthorCopyright:HtmlEncode}</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
<key>NSMainStoryboardFile</key>
<string>Main</string>
<key>XSAppIconAssets</key>
<string>Assets.xcassets/AppIcon.appiconset</string>
</dict>
</plist>
64 changes: 64 additions & 0 deletions tests/perftest/Main.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;

using AppKit;
using BenchmarkDotNet.Columns;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Exporters.Csv;
using BenchmarkDotNet.Exporters.Json;
using BenchmarkDotNet.Jobs;
using BenchmarkDotNet.Reports;
using BenchmarkDotNet.Running;
using BenchmarkDotNet.Toolchains.InProcess.Emit;
using Perfolizer.Horology;

namespace PerfTest {
static class MainClass {
static int Main (string [] args)
{
try {
// The call to NSApplication.Init is required
NSApplication.Init ();
BenchmarkRunner.Run (typeof (MainClass).Assembly, new Config ());
} catch (Exception e) {
Console.WriteLine ("Unhandled exception: {0}", e);
return 1;
}

return 0;
}
}

public class Config : ManualConfig {
public Config ()
{
AddJob (Job.ShortRun
.WithLaunchCount (1)
.WithToolchain (new InProcessEmitToolchain (TimeSpan.FromHours (1), true))
.WithId ("InProcess")
);

var artifactsPath = Environment.GetEnvironmentVariable ("BENCHMARK_OUTPUT_PATH");
if (!string.IsNullOrEmpty (artifactsPath))
WithArtifactsPath (artifactsPath);

WithOption (ConfigOptions.DisableOptimizationsValidator, true);
WithOption (ConfigOptions.JoinSummary, true);

AddLogger (DefaultConfig.Instance.GetLoggers ().ToArray ()); // manual config has no loggers by default
AddExporter (DefaultConfig.Instance.GetExporters ().Where (v => !(v is CsvExporter)).ToArray ()); // manual config has no exporters by default

var csv = new CsvExporter (
CsvSeparator.Semicolon,
new SummaryStyle (CultureInfo.CurrentCulture, true, SizeUnit.B, TimeUnit.Nanosecond, false, true)
);
AddExporter (csv);
AddExporter (JsonExporter.Full);

AddColumnProvider (DefaultConfig.Instance.GetColumnProviders ().ToArray ()); // manual config has no columns by default
}
}
}
Loading

0 comments on commit 5448fbe

Please sign in to comment.