Sha256: 5c867a0fb64f0996dc498eb6d1cf3271a1695a23b30705374ce0980f7840056a

Contents?: true

Size: 725 Bytes

Versions: 3

Compression:

Stored size: 725 Bytes

Contents

require 'benchmark/ips'
require 'strings'

text = "Ignorance is the parent of fear."

Benchmark.ips do |x|
  x.report('wrap') do
    Strings::Wrap.wrap(text, 10)
  end

  x.report('truncate') do
    Strings::Truncate.truncate(text, 10)
  end

  x.compare!
end

# (2017-12-09)
#
# Calculating -------------------------------------
#                 wrap       186 i/100ms
#             truncate       295 i/100ms
# -------------------------------------------------
#                 wrap     1917.2 (±2.2%) i/s -       9672 in   5.047297s
#             truncate     3020.6 (±3.0%) i/s -      15340 in   5.083516s
#
# Comparison:
#             truncate:     3020.6 i/s
#                 wrap:     1917.2 i/s - 1.58x slower
#

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
strings-0.1.2 benchmarks/speed_profile.rb
strings-0.1.1 benchmarks/speed_profile.rb
strings-0.1.0 benchmarks/speed_profile.rb