SymbolicML / DynamicQuantities.jl

Efficient and type-stable physical quantities in Julia
https://symbolicml.org/DynamicQuantities.jl/dev/
Apache License 2.0
120 stars 15 forks source link

Fix reflection by using `dimension_names` #135

Closed MilesCranmer closed 1 month ago

MilesCranmer commented 1 month ago

Seems sometimes inference issues propagate to the all_dimensions function's use of Base.fieldnames. Switching to the internally-defined dimension_names fixes it.

TODO: verify this does not affect performance!

github-actions[bot] commented 1 month ago

Benchmark Results

main b1ae402e89a831... main/b1ae402e89a831...
Quantity/creation/Quantity(x) 2.79 ± 0.009 ns 2.79 ± 0.009 ns 1
Quantity/creation/Quantity(x, length=y) 3.41 ± 0.01 ns 3.41 ± 0.01 ns 1
Quantity/with_numbers/*real 3.1 ± 0.01 ns 3.1 ± 0.01 ns 1
Quantity/with_numbers/^int 8.05 ± 2.2 ns 8.05 ± 2.2 ns 1
Quantity/with_numbers/^int * real 8.37 ± 1.9 ns 8.37 ± 1.9 ns 1
Quantity/with_quantity/+y 4.04 ± 0.01 ns 4.04 ± 0.001 ns 1
Quantity/with_quantity//y 3.11 ± 0 ns 3.11 ± 0 ns 1
Quantity/with_self/dimension 3.11 ± 0.01 ns 3.11 ± 0.001 ns 1
Quantity/with_self/inv 3.11 ± 0.001 ns 3.11 ± 0.001 ns 1
Quantity/with_self/ustrip 2.79 ± 0 ns 2.79 ± 0.009 ns 1
QuantityArray/broadcasting/multi_array_of_quantities 0.143 ± 0.00064 ms 0.146 ± 0.0009 ms 0.979
QuantityArray/broadcasting/multi_normal_array 0.0559 ± 0.0029 ms 0.0559 ± 0.0029 ms 1
QuantityArray/broadcasting/multi_quantity_array 0.155 ± 0.00082 ms 0.155 ± 0.00064 ms 1
QuantityArray/broadcasting/x^2_array_of_quantities 24.5 ± 2.5 μs 24.1 ± 2.3 μs 1.02
QuantityArray/broadcasting/x^2_normal_array 4.79 ± 0.95 μs 5.43 ± 0.66 μs 0.882
QuantityArray/broadcasting/x^2_quantity_array 7.1 ± 0.29 μs 7.02 ± 0.26 μs 1.01
QuantityArray/broadcasting/x^4_array_of_quantities 0.0816 ± 0.00064 ms 0.0815 ± 0.00052 ms 1
QuantityArray/broadcasting/x^4_normal_array 0.0499 ± 0.00017 ms 0.0499 ± 0.00018 ms 1
QuantityArray/broadcasting/x^4_quantity_array 0.053 ± 0.00022 ms 0.053 ± 0.00021 ms 1
time_to_load 0.145 ± 0.0023 s 0.145 ± 0.00088 s 0.998

Benchmark Plots

A plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. Go to "Actions"->"Benchmark a pull request"->[the most recent run]->"Artifacts" (at the bottom).