UnitsNet icon indicating copy to clipboard operation
UnitsNet copied to clipboard

Annotate is native aot compatible

Open OleRoss opened this issue 10 months ago • 3 comments

Dupliate of deleted #1532

OleRoss avatar Apr 13 '25 08:04 OleRoss

@angularsen I rebased on the current master - it was much easier due to the latest commits

And, just for fun, I added a startup performance comparison :)

Default startup performance (PerfTest_Startup):

| Name      | Mean            | StdDev        | StdErr       | Min             | Max             | P95             | P90             | Outliers |
| --------- | --------------- | ------------- | ------------ | --------------- | --------------- | --------------- | --------------- | -------- |
| Default   | 2463,4326ms     | 386,9283ms    | 88,7674ms    | 1930,7473ms     | 3242,5405ms     | 3182,9327ms     | 3017,8285ms     | 1        |

NativeAot compilation startup performance (PerfTest_Startup_Aot):

| Name    | Mean      | StdDev   | StdErr    | Min        | Max        | P95        | P90 | Outliers |
| ------- | --------- | -------- | --------- | ---------- | ---------- | ---------- | --- | -------- |
| Default | 186,438ms | 47,942ms | 10,9986ms | 280,4149ms | 279,2135ms | 275,9632ms | 1   |          |

OleRoss avatar Apr 25 '25 17:04 OleRoss

@angularsen I rebased on the current master - it was much easier due to the latest commits

And, just for fun, I added a startup performance comparison :)

Default startup performance (PerfTest_Startup):

| Name      | Mean            | StdDev        | StdErr       | Min             | Max             | P95             | P90             | Outliers |
| --------- | --------------- | ------------- | ------------ | --------------- | --------------- | --------------- | --------------- | -------- |
| Default   | 2463,4326ms     | 386,9283ms    | 88,7674ms    | 1930,7473ms     | 3242,5405ms     | 3182,9327ms     | 3017,8285ms     | 1        |

NativeAot compilation startup performance (PerfTest_Startup_Aot):

| Name    | Mean      | StdDev   | StdErr    | Min        | Max        | P95        | P90 | Outliers |
| ------- | --------- | -------- | --------- | ---------- | ---------- | ---------- | --- | -------- |
| Default | 186,438ms | 47,942ms | 10,9986ms | 280,4149ms | 279,2135ms | 275,9632ms | 1   |          |

@OleRoss I haven't been able to do my own aot-enabled publish (haven't installed the c++ stuff yet), but am very curious to see how the 🐲 version performs: if you got the time, could you please run it against this PR: https://github.com/angularsen/UnitsNet/pull/1544

lipchev avatar Apr 25 '25 17:04 lipchev

@lipchev, sure, I played around with it, but had difficulties getting comparable results ...

I ended up creating a benchmark class which starts a process and waits for completion:

Run 1: IterationCount=20  LaunchCount=8  WarmupCount=5

| Method                         | Mean     | Error   | StdDev   |
|------------------------------- |---------:|--------:|---------:|
| MeasureStartupQuantityValue    | 869.8 ms | 6.28 ms | 23.37 ms |
| MeasureStartupQuantityValueAot | 204.2 ms | 3.39 ms | 12.59 ms |
| MeasureStartupMaster           | 491.9 ms | 3.51 ms | 12.75 ms |
| MeasureStartupMasterAot        | 171.7 ms | 1.48 ms |  5.49 ms |

Run 2: IterationCount=20  LaunchCount=8  WarmupCount=5

| Method                         | Mean     | Error   | StdDev   | Median   |
|------------------------------- |---------:|--------:|---------:|---------:|
| MeasureStartupMaster           | 535.9 ms | 4.45 ms | 16.33 ms | 534.7 ms |
| MeasureStartupMasterAot        | 181.8 ms | 9.68 ms | 36.27 ms | 173.1 ms |
| MeasureStartupQuantityValue    | 798.5 ms | 7.67 ms | 28.29 ms | 792.3 ms |
| MeasureStartupQuantityValueAot | 200.9 ms | 1.78 ms |  6.60 ms | 199.7 ms |

Between Run 1 and Run 2, I changed the order of the tests; Somehow, the tests seem to be affected by this, but I think the trend is clear.

Apart from that, those are the results using timeitsharp (very inconsistent, just for completeness):

fractional-quantity-value:

| Name        | Mean        | StdDev      | StdErr      | Min         | Max         | P95         | P90        | Outliers |
| ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ----------- | ---------- | -------- |
| Default     | 1737,353ms  | 321,2004ms  | 73,6884ms   | 1378,0007ms | 2417,7457ms | 2345,5968ms | 2174,4889m | 1        |

fractional-quantity-value AOT:

| Name    | Mean       | StdDev    | StdErr   | Min        | Max       | P95        | P90 | Outliers |
| ------- | ---------- | --------- | -------- | ---------- | --------- | ---------- | --- | -------- |
| Default | 106,8239ms | 11,6117ms | 2,7369ms | 142,3908ms | 136,828ms | 118,7921ms | 2   |          |


master:

| Name        | Mean        | StdDev      | StdErr      | Min        | Max         | P95         | P90         | Outliers |
| ----------- | ----------- | ----------- | ----------- | ---------- | ----------- | ----------- | ----------- | -------- |
| Default     | 955,7565ms  | 200,4313ms  | 45,9821ms   | 739,7095ms | 1324,9328ms | 1324,5596ms | 1312,1677ms | 1        |

master AOT:

| Name    | Mean       | StdDev    | StdErr   | Min        | Max      | P95        | P90 | Outliers |
| ------- | ---------- | --------- | -------- | ---------- | -------- | ---------- | --- | -------- |
| Default | 108,8349ms | 10,5986ms | 2,3699ms | 127,2372ms | 125,85ms | 123,0387ms | 0   |          |

OleRoss avatar Apr 26 '25 10:04 OleRoss

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.

github-actions[bot] avatar Jun 26 '25 02:06 github-actions[bot]

This PR was automatically closed due to inactivity.

github-actions[bot] avatar Jul 03 '25 02:07 github-actions[bot]

Apologies, I've been away for some time. What is the state of this

angularsen avatar Jul 26 '25 12:07 angularsen

Merged with latest master, separated out some diffs to make the PR more succinct. LGTM.

angularsen avatar Jul 26 '25 13:07 angularsen

Thanks for taking the time and merging @angularsen

OleRoss avatar Jul 26 '25 13:07 OleRoss

Better late than never, I've heard 🙈

angularsen avatar Jul 26 '25 15:07 angularsen