Skip to content

Fix pow performance#106

Merged
devmotion merged 2 commits into
JuliaMath:masterfrom
hersle:base_pow
Jun 10, 2026
Merged

Fix pow performance#106
devmotion merged 2 commits into
JuliaMath:masterfrom
hersle:base_pow

Conversation

@hersle

@hersle hersle commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Addresses #105. Similar to #85. Now the example code in the issue on my machine gives:

T = Float32, sign = 1:
  10.300 ns (0 allocations: 0 bytes)
  10.300 ns (0 allocations: 0 bytes)
T = Float32, sign = -1:
  2.700 ns (0 allocations: 0 bytes)
  2.500 ns (0 allocations: 0 bytes)
T = Float64, sign = 1:
  16.200 ns (0 allocations: 0 bytes)
  16.100 ns (0 allocations: 0 bytes)
T = Float64, sign = -1:
  2.700 ns (0 allocations: 0 bytes)
  2.500 ns (0 allocations: 0 bytes)

Anything I am overlooking here?

@codecov

codecov Bot commented Jun 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.63%. Comparing base (e62c849) to head (27fde84).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #106      +/-   ##
==========================================
+ Coverage   94.15%   94.63%   +0.47%     
==========================================
  Files           1        1              
  Lines         154      149       -5     
==========================================
- Hits          145      141       -4     
+ Misses          9        8       -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread test/runtests.jl Outdated
Comment thread src/NaNMath.jl Outdated
@hersle

hersle commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Added @devmotion's suggestion and removed unreliable performance tests. Instead, here are results from my machine:

using NaNMath, BenchmarkTools
for T in (Float16, Float32, Float64)
    x, y = rand(T), rand(T) # in (0, 1)
    println("T=$T: ", (@belapsed NaNMath.pow($x, $y)) / (@belapsed Base.:^($x, $y)))
end

Before this PR:

T=Float16: 0.9996094659628969
T=Float32: 3.3202716041996956
T=Float64: 3.0019657223244507

After this PR:

T=Float16: 1.0047619047619047
T=Float32: 1.0098039215686276
T=Float64: 0.9878048780487806

@devmotion devmotion left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, can you update the version number?

@hersle

hersle commented Jun 10, 2026

Copy link
Copy Markdown
Contributor Author

Sure, like so? I can't tag the release, though.

@devmotion devmotion merged commit 2361ed0 into JuliaMath:master Jun 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants