Sha256: b0e67e9712f716a7ed68c997e85362245db2b58586785844b8a356eccd948a3e

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

$:.unshift File.expand_path("../../lib", __FILE__)

require 'benchmark'
require 'daru'

df = Daru::DataFrame.new({
  a: 100000.times.map { rand },
  b: 100000.times.map { rand },
  c: 100000.times.map { rand }
})

Benchmark.bm do |x|
  x.report("Set a single row with Array") do
    df.row[5] = [55,22,65]
  end

  x.report("Set a single row with Daru::Vector") do
    df.row[3456] = Daru::Vector.new([3,54,11], index: [:b,:e,:a])
  end

  x.report("Create a new row with Array") do
    df.row[100001] = [34,66,11]
  end

  x.report("Create a new row with Daru::Vector") do
    df.row[100005] = Daru::Vector.new([34,66,11], index: [:a,:b,:t])
  end
end

#                      ==== Benchmarks ====
#
#                                       user     system      total        real
# Set a single row with Array         0.600000   0.000000   0.600000 (  0.604718)
# Set a single row with Daru::Vector  0.600000   0.000000   0.600000 (  0.598599)
# Create a new row with Array         0.840000   0.010000   0.850000 (  0.858349)
# Create a new row with Daru::Vector  0.950000   0.000000   0.950000 (  0.950725)

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
daru-0.3 benchmarks/row_assign.rb
daru-0.2.2 benchmarks/row_assign.rb
daru-0.2.1 benchmarks/row_assign.rb
daru-0.2.0 benchmarks/row_assign.rb
daru-0.1.6 benchmarks/row_assign.rb
daru-0.1.5 benchmarks/row_assign.rb
daru-0.1.4.1 benchmarks/row_assign.rb
daru-0.1.4 benchmarks/row_assign.rb
daru-0.1.3.1 benchmarks/row_assign.rb
daru-0.1.3 benchmarks/row_assign.rb
daru-0.1.2 benchmarks/row_assign.rb
daru-0.1.1 benchmarks/row_assign.rb