Giter Site home page Giter Site logo

Comments (2)

Roger-luo avatar Roger-luo commented on May 24, 2024

It will be more obvious when you pack a few instruct together, e.g using chained put blocks.

using StaticArrays, BenchmarkTools
U = @SMatrix rand(ComplexF64, 2, 2)
st = rand(ComplexF64, 1<<20)
julia> @benchmark foreach(k->instruct2!($st, $U, 2), 1:100)
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     180.581 ms (0.00% GC)
  median time:      186.595 ms (0.00% GC)
  mean time:        186.496 ms (0.00% GC)
  maximum time:     193.396 ms (0.00% GC)
  --------------
  samples:          27
  evals/sample:     1

julia> @benchmark foreach(k->instruct2!($st, $(Matrix(U)), 2), 1:100)
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     169.435 ms (0.00% GC)
  median time:      187.297 ms (0.00% GC)
  mean time:        188.134 ms (0.00% GC)
  maximum time:     208.341 ms (0.00% GC)
  --------------
  samples:          27
  evals/sample:     1

from yaoblocks.jl.

Roger-luo avatar Roger-luo commented on May 24, 2024

But SMatrix should be faster

julia> @benchmark foreach(k->instruct3!($st, $U, 2), 1:100)
BenchmarkTools.Trial:
  memory estimate:  80 bytes
  allocs estimate:  1
  --------------
  minimum time:     10.900 ns (0.00% GC)
  median time:      13.812 ns (0.00% GC)
  mean time:        24.196 ns (38.99% GC)
  maximum time:     50.778 μs (99.92% GC)
  --------------
  samples:          10000
  evals/sample:     998

julia> @benchmark foreach(k->instruct3!($st, $(Matrix(U)), 2), 1:100)
BenchmarkTools.Trial:
  memory estimate:  0 bytes
  allocs estimate:  0
  --------------
  minimum time:     63.906 ns (0.00% GC)
  median time:      67.717 ns (0.00% GC)
  mean time:        71.838 ns (0.00% GC)
  maximum time:     212.529 ns (0.00% GC)
  --------------
  samples:          10000
  evals/sample:     976

from yaoblocks.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.