A really basic in-app profiler for Xamarin and UWP applications.
A memory profiler is available and will track a set of registered instances in a loop (be careful, this process is heavy and don't activate this functionality in production).
First, register any instance you want to profile
public ViewController()
{
Debugging.Profiler.Default.Memory.Register(this);
}
You can also define a unique key (by default its instance HashCode).
public ViewController()
{
Debugging.Profiler.Default.Memory.Register(this, "MyVC");
}
Finally, you can track and log properties on your profiled instances.
public ViewController()
{
Debugging.Profiler.Default.Memory.Register(this, nameof(Title));
}
Debugging.Profiler.Default.Start();
To display the profiler view use the Show
method.
Debugging.Profiler.Default.Show();
A shake gesture is a common scenario for showing this view.
// iOS : AppDelegate
UIApplication.SharedApplication.ApplicationSupportsShakeToEdit = true;
// iOS : Root view controller
public override void MotionEnded(UIEventSubtype motion, UIEvent evt)
{
if (motion == UIEventSubtype.MotionShake)
{
Debugging.Profiler.Default.Show();
}
}
// Android : Activities
private ShakeListener shake;
protected override void OnResume()
{
base.OnResume();
shake = ShakeListener.Register(this);
shake.Shaked += OnShaked;
}
protected override void OnPause()
{
base.OnPause();
shake.Unregister();
}
private void OnShaked(object sender, System.EventArgs e)
{
shake.Shaked -= OnShaked;
Debugging.Profiler.Default.Show(this);
}
-
Profiling
-
iOS View
-
iOS Sample
-
Android View (In-Progress)
-
Android Sample
-
NuGet package
-
Add filters to views
-
Add graphs to views
Contributions are welcome! If you find a bug please report it and if you want a feature please report it.
If you want to contribute code please file an issue and create a branch off of the current dev branch and file a pull request.
MIT © Aloïs Deniel