-
Notifications
You must be signed in to change notification settings - Fork 632
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deno.KV - Modernized TypeScript randomULID() Generator - Smaller and Optimized #3675
Comments
|
What is the advantage of this implementation over the one in https://deno.land/std/ulid ? I feel like I am misunderstanding. Is it faster? I'd love to get a benchmark there. |
The ULID implementation in the Standard Library is up to 58% faster and easier to understand. Script: import { ulid } from "https://deno.land/std@0.202.0/ulid/mod.ts";
Deno.bench("ulid()", { baseline: true }, () => { ulid() });
Deno.bench("randomULID()", () => { randomULID() }) Results (consistent with other runs):
However, once you remove Results (consistent with other runs and swapping baseline benchmarks):
Really, the Standard Library implementation is still bloody quick. I can't see it being a bottleneck and, therefore, needing further performance optimisation. Either way, it'd be best to submit a PR to https://github.com/denoland/deno_std with these ULID tweaks, and we can go from there. This issue should be moved there too. While related to Deno KV, the ULID implementation lives there 🙂 |
@suchislife801 Our version is much simpler than the reference implementation at https://github.com/ulid/javascript Also we use |
The issue with not using the factory function in the case of us having a factory function is that we need to test the implementation. It's pretty hard to test with stubbing the randomness of the implementation. If you could show a proper way to test your proposed implementation that was simpler I'd love to take a look. |
Let's try to be respectful here. When I'm talking about testing, I am referring to unit testing. The code you posted, while cool, is definitely closer to "fuzzing" than "testing". Properly testing things like MULID requires more than just fuzzing, unfortunately. That being said, any reasonably correct ULID implementation will essentially never get a collision, so I see the value in testing that. If you would like, you could PR your collision test file into the |
Sure, thanks for opening an issue. I'd love to chat more if you are interested. |
I am interested in deleting this entire issue but that is also not possible. |
Modernized Javascript randomULID() Generator - Smaller and Optimized
The text was updated successfully, but these errors were encountered: