Closed naitoh closed 4 years ago
I rewrote the at() method using C language. The result is up to x18 times faster.
$ benchmark-driver diagonal_at_fp32_diff.yaml Calculating ------------------------------------- numo-narray 0.9.1.4 numo-narray 0.9.2.1 a.at(Array, Array) 546.533 9.840k i/s - 1.000k times in 1.829716s 0.101628s l.at(Numo::Int32(X).seq, Numo::Int32(X).seq) 2.203k 7.935k i/s - 1.000k times in 0.453879s 0.126025s
Comparison: a.at(Array, Array) numo-narray 0.9.2.1: 9839.8 i/s numo-narray 0.9.1.4: 546.5 i/s - 18.00x slower
l.at(Numo::Int32(X).seq, Numo::Int32(X).seq) numo-narray 0.9.2.1: 7934.9 i/s numo-narray 0.9.1.4: 2203.2 i/s - 3.60x slower
$ cat diagonal_at_fp32_diff.yaml contexts: - gems: { numo-narray: 0.9.1.4 } require: false prelude: | require 'numo/narray' - gems: { numo-narray: 0.9.2.1 } require: false prelude: | require 'numo/narray' loop_count: 1000 prelude: | require 'numo/narray' X = 10000 a = Numo::SFloat.new(X, X).seq(0) b = Numo::SFloat.new(X, X).seq(0) x = Numo::Int32.new(X).seq.to_a y = Numo::Int32.new(X).seq sleep 30 benchmark: 'a.at(Array, Array) ' : a.at(x, x) 'l.at(Numo::Int32(X).seq, Numo::Int32(X).seq)' : b.at(y, y)
Thanks!
I rewrote the at() method using C language. The result is up to x18 times faster.
Ruby 2.5.3 (Linux)
Comparison: a.at(Array, Array)
numo-narray 0.9.2.1: 9839.8 i/s numo-narray 0.9.1.4: 546.5 i/s - 18.00x slower
benchmark code