Ruby version 3? #2
Closed
bcollierjones
started this conversation in
Ideas
Replies: 2 comments 3 replies
|
Try v0.1.1? |
2 replies
|
This is probably unrelated to Ruby, and might be purely cosmetic, so I can put this in a new discussion if necessary or just ignore it because it is working as intended. I wrote a small script to see how the length of sqids change compared to hash ids. Ideally we'd like to pick a minimum length that will stay relatively consistent and only grow longer late into the product lifecycle. However, while sqids definitely produce more random batches of characters, the length of the sqids swings back and forth. Here is sample code and output to demonstrate: Sample OutputCodedef test
sqid_encoder = Sqids.new
hashid_encoder = Hashids.new
sqid_size = 0
hashid_size = 0
i = 0
1_000_0000.times do |i|
new_sqid = sqid_encoder.encode([i])
new_hashid = hashid_encoder.encode([i])
if new_sqid.size != sqid_size || new_hashid.size != hashid_size
puts "%8d : %12s / %12s" % [i, new_sqid, new_hashid]
sqid_size = new_sqid.size if new_sqid.size != sqid_size
hashid_size = new_hashid.size if new_hashid.size != hashid_size
end
end
end |
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Any chance of support for Ruby 3.0? Unfortunately, we can't use ruby 3.1 just yet.
All reactions