dotnet / dotnet/android

Increased Runtime Duration for Java Functions in .NET Android Compared to Xamarin Android

Open
#9,601 6 comments 0 reactions 1 assignee Assigned to @jonathanpeppers View on GitHub
Area: Performance need-attention
Dominant language
C#
Stars
2.1k
Forks
579
Avg merge
1d 20h
Merged PRs (30d)
257

Description

### Android framework version

net9.0-android, net8.0-android

### Affected platform version

VS 2022 17.12.3

### Description

I recently converted a Xamarin Android app to .NET Android (net8.0-android). I noticed that while the startup performance has improved, other functions are taking longer to execute at runtime. This is particularly evident when executing Java functions. In a simple comparison between Xamarin and .NET, I measured the following times for executing Java.Lang.Math.Sqrt:

- Xamarin: 14 µs
- .NET: 25 µs

How can this significant performance difference be explained?

Attached is a speedscope file that I recorded for the .NET app.
[dotnet-dsrouter.exe_20241208_140545.speedscope.json](https://github.com/user-attachments/files/18052457/dotnet-dsrouter.exe_20241208_140545.speedscope.json)

### Steps to Reproduce

N/A

### Did you find any workaround?

N/A

### Relevant log output

```shell

```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.