22ccf2e81b
This is another example that p/invokes are much faster than calling selectors. Beside the generator the manual bindings were updated to use the newer API and the old one was decorated as `[Obsolete]`. | Method | name | value | Mean | Error | StdDev | |------------------------------ |-------------- |--------------------- |----------------:|----------------:|--------------:| | CFArray_StringArrayFromHandle | empty | () | 123.9 ns | 68.92 ns | 3.78 ns | | NSArray_StringArrayFromHandle | empty | () | 1,422.6 ns | 25.83 ns | 1.42 ns | | CFArray_StringArrayFromHandle | few | ( (...).") [108] | 1,885.2 ns | 46.37 ns | 2.54 ns | | NSArray_StringArrayFromHandle | few | ( (...).") [108] | 8,530.0 ns | 594.40 ns | 32.58 ns | | CFArray_StringArrayFromHandle | large_mutable | ((...)) [8419330] | 15,821,101.0 ns | 4,803,631.19 ns | 263,303.23 ns | | NSArray_StringArrayFromHandle | large_mutable | ((...)) [8419330] | 22,823,871.9 ns | 6,589,380.43 ns | 361,186.18 ns | | CFArray_StringArrayFromHandle | mutable | ( (...)9e") [54] | 867.4 ns | 59.23 ns | 3.25 ns | | NSArray_StringArrayFromHandle | mutable | ( (...)9e") [54] | 4,939.6 ns | 203.28 ns | 11.14 ns | note: `NSArray.StringArrayFromHandle` was already using (p/invoke-based) `CFString.FromHandle` instead of (selector-based) `NSString.FromHandle` to create the managed `string` instances inside the `string[]`. |
||
---|---|---|
.. | ||
Assets.xcassets | ||
dotnet | ||
legacy | ||
.gitignore | ||
AppDelegate.cs | ||
Entitlements.plist | ||
Info.plist | ||
Main.cs | ||
Main.storyboard | ||
Makefile | ||
MessageSend.cs | ||
Messaging.cs | ||
ObjCBridge.cs | ||
ObjectCreation.cs | ||
README.md | ||
TollFreeBridge.cs | ||
ViewController.cs | ||
ViewController.designer.cs | ||
perftest.sln |
README.md
Benchmarks
This folder contains a test suite to test performance in Xamarin.iOS/Xamarin.Mac.
There are three variations of the test suite:
-
Legacy mode (Xamarin).
-
.NET Mode (Mono): runs tests in .NET, with MonoVM.
-
.NET Mode (CoreCLR): runs tests using .NET, with CoreCLR.
Running the benchmarks
Run all three variations of the test suite:
make run-perftest
Run each variation:
Legacy mode
make run-perftest-with-legacy
.NET Mode (Mono)
make run-perftest-with-mono
.NET Mode (CoreCLR)
make run-perftest-with-coreclr
Results
At the end of the test run, something like this will be printed:
Log files were stored in xamarin-macios/tests/perftest/output/2021-04-22--21:43:28
and that's where you'll find log files. Console output from the executable is stored as perflog-[timestamp].log, while BenchmarkDotNet results are exported to the results/ subfolder (in json, markdown, csv and html formats).
There's no easy way to compare results across variations or runs (yet), the exported results will have to be examined by a human and compared that way.