xamarin-macios/tests/perftest
Sebastien Pouliot 22ccf2e81b
[generator] Use new `CFArray.StringArrayFromHandle` instead of the existing `NSArray` API (#12368)
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[]`.
2021-08-06 09:17:48 -04:00
..
Assets.xcassets [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
dotnet [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
legacy [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
.gitignore [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
AppDelegate.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Entitlements.plist [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Info.plist [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Main.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Main.storyboard [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Makefile [dotnet] Remove the .NET workload resolver workaround, it's not needed anymore. (#11695) 2021-05-27 07:30:46 +02:00
MessageSend.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
Messaging.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
ObjCBridge.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
ObjectCreation.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
README.md [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
TollFreeBridge.cs [generator] Use new `CFArray.StringArrayFromHandle` instead of the existing `NSArray` API (#12368) 2021-08-06 09:17:48 -04:00
ViewController.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
ViewController.designer.cs [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00
perftest.sln [tests] Add a performance test using BenchmarkDotNet. (#11298) 2021-04-23 13:29:06 +02:00

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.