Sha256: add14786ab6ec8807e52e83254063ad243f383f63c2e040531486b37d6599bfb

Contents?: true

Size: 722 Bytes

Versions: 15

Compression:

Stored size: 722 Bytes

Contents

require 'benchmark'
require 'ipaddr'

Benchmark.bm do |x|
  x.report {
    # Implementation pre v3.11.0
    ip = 3232235521
    2000000.times do
      IPAddr.new_ntoh([ip].pack('N')).to_s
    end }

  x.report {
    # Implementation as of v3.11.2
    ip = 3232235521
    2000000.times do
      [ip].pack('N').unpack('C4').join('.')
    end }

  x.report {
    ip = 3232235521
    2000000.times do
      b = "%08x" % ip
      "%d.%d.%d.%d" % [b[0..1].to_i(16), b[2..3].to_i(16), b[4..5].to_i(16), b[6..7].to_i(16)]
    end }

end

#       user     system      total        real
#  21.330000   0.000000  21.330000 ( 21.348559)
#   4.410000   0.000000   4.410000 (  4.411973)
#   6.450000   0.000000   6.450000 (  6.446321)

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
logstash-codec-netflow-4.1.2 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-4.1.1 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-4.1.0 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-4.0.2 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-4.0.1 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-4.0.0 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.14.1 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.14.0 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.13.2 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.13.1 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.13.0 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.12.0 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.11.4 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.11.3 spec/codecs/benchmarks/IPAddr.rb
logstash-codec-netflow-3.11.2 spec/codecs/benchmarks/IPAddr.rb