GithubHelp home page GithubHelp logo

Comments (10)

cortner avatar cortner commented on June 1, 2024

.... indeed as I'm writing this it occured to me that ForwardDiff will probably get very good performance:

[ Info: And with FOrwardDiff
  14.570 ns (0 allocations: 0 bytes)

from interpolations.jl.

mkitti avatar mkitti commented on June 1, 2024

Could you provide the code that generated the benchmark?

from interpolations.jl.

cortner avatar cortner commented on June 1, 2024

trying to reduce it to a short script, the weirdest thing happened:

using Interpolations, ForwardDiff 
rr = range(0.0, stop=5.0, length=10_000)
spl = cubic_spline_interpolation(rr, sin.(rr))
r = rand() * 5
print("Evaluation: "); @btime $spl($r)
print(" gradient1: "); @btime Interpolations.gradient1($spl, $r)
print("      Dual: "); @btime $spl(ForwardDiff.Dual($r, 1))

rr = range(0.0, stop=5.0, length=10_000)
spl = cubic_spline_interpolation(rr, sin.(rr))
r = rand() * 5
@btime $spl($r)
@btime Interpolations.gradient1($spl, $r)
@btime $spl(ForwardDiff.Dual($r, 1))

produces output

Evaluation:   8.717 ns (0 allocations: 0 bytes)
 gradient1:   12.345 ns (0 allocations: 0 bytes)
      Dual:   15.030 ns (0 allocations: 0 bytes)
  8.717 ns (0 allocations: 0 bytes)
  56.682 ns (0 allocations: 0 bytes)
  15.030 ns (0 allocations: 0 bytes)

Most likely a problem with benchmarking and not with Interpolations.jl, please close this if you agree.

from interpolations.jl.

mkitti avatar mkitti commented on June 1, 2024

Try running with @benchmark to get more statistics.

from interpolations.jl.

cortner avatar cortner commented on June 1, 2024

with @benchmark the discrepancy does not occur. If you agree, we close this and I file an issue with BenchmarkTools

from interpolations.jl.

mkitti avatar mkitti commented on June 1, 2024

That is intriguing. How so?

@btime reports the fastest time. @benchmark obviously provides more statistics. Perhaps more autodiff is occurring on the first run than the second run?

from interpolations.jl.

cortner avatar cortner commented on June 1, 2024

that would not explain it. The weird time is already the second run.

from interpolations.jl.

mkitti avatar mkitti commented on June 1, 2024

Is the weird time the faster time?

from interpolations.jl.

cortner avatar cortner commented on June 1, 2024

No - the slow time. The fast time is consistent with what I'm expecting to see.

from interpolations.jl.

cortner avatar cortner commented on June 1, 2024

I cannot reproduce in latest versions.

from interpolations.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.