Sha256: 726a99c6ec3d23d983efb00ca4a020e1a29a2d447bdd8c67ac9262052a529b12

Contents?: true

Size: 653 Bytes

Versions: 6

Compression:

Stored size: 653 Bytes

Contents

# frozen_string_literal: true

%w[lib benchmarks].each { |name| $LOAD_PATH.unshift(name) }

require "benchmark/ips"
require "lite/uxid"

Benchmark.ips do |x|
  x.report("Hashid") do
    id = rand(1..1_000_000)
    Lite::Uxid::Hashid.encode(id)
  end

  x.report("NanoID") do
    _id = rand(1..1_000_000) # To simulate the extra work from `rand`
    Lite::Uxid::Nanoid.encode
  end

  x.report("ULID") do
    _id = rand(1..1_000_000) # To simulate the extra work from `rand`
    Lite::Uxid::Ulid.encode
  end

  x.report("UUID") do
    _id = rand(1..1_000_000) # To simulate the extra work from `rand`
    Lite::Uxid::Uuid.encode
  end

  x.compare!
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
lite-uxid-2.0.0 benchmarks/compare.rb
lite-uxid-1.5.2 benchmarks/compare.rb
lite-uxid-1.5.1 benchmarks/compare.rb
lite-uxid-1.5.0 benchmarks/compare.rb
lite-uxid-1.4.0 benchmarks/compare.rb
lite-uxid-1.3.0 benchmarks/compare.rb