benchmarks/compare.rb in lite-uxid-1.2.0 vs benchmarks/compare.rb in lite-uxid-1.3.0
- old
+ new
@@ -5,18 +5,26 @@
require "benchmark/ips"
require "lite/uxid"
Benchmark.ips do |x|
x.report("Hashid") do
- Lite::Uxid::Hashid.encode(rand(1..1_000_000))
+ 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