All Projects → krthr → uuix

krthr / uuix

Licence: MIT License
A tiny (<1KB) and fast UUID (v4) generator for Crystal

Programming Languages

crystal
512 projects
Dockerfile
14818 projects

Projects that are alternatives of or similar to uuix

fastuuid
FastUUID is a library which provides CPython bindings to Rust's UUID library
Stars: ✭ 83 (+388.24%)
Mutual labels:  uuid, uuid4
php-uuid
RFC 4122 compliant UUID generator and parser for PHP.
Stars: ✭ 13 (-23.53%)
Mutual labels:  uuid, uuid4
LAB
MIT IT Lab Repository
Stars: ✭ 23 (+35.29%)
Mutual labels:  mit
user
A domain layer providing basic user management
Stars: ✭ 14 (-17.65%)
Mutual labels:  uuid
micell
A collection of functions for front-end development
Stars: ✭ 16 (-5.88%)
Mutual labels:  uuid
praetorian
A minimalist Crystal authorization system inspired by https://github.com/varvet/pundit.
Stars: ✭ 54 (+217.65%)
Mutual labels:  crystal-language
burocracia.cr
No dependency Crystal shard to validate, generate and format Brazilian burocracias such as CPF, CNPJ and CEP
Stars: ✭ 21 (+23.53%)
Mutual labels:  crystal-language
documentation
Pterodactyl's documentation is open source! This repository contains the documentation for installing and updating both the panel and the daemon.
Stars: ✭ 99 (+482.35%)
Mutual labels:  mit
Square
The Square Programming Language. A tiny programming language under 200kb.
Stars: ✭ 23 (+35.29%)
Mutual labels:  tiny
Butterfly
分布式ID生成器框架:超高性能的发号器框架。通过引入多种新的方案,彻底解决雪花算法的时间回拨等问题,并将雪花算法原生QPS提高最少十几~二十倍
Stars: ✭ 111 (+552.94%)
Mutual labels:  uuid
permissionary
Tiny and framework-agnostic role-based permission management using composition over inheritance
Stars: ✭ 19 (+11.76%)
Mutual labels:  tiny
tiny-framework
A light wight easy to use RESTful apis framework for education & demo purposes. stripped down framework to the fundamental components that that every one would essentially need to (learn / make a demo application).
Stars: ✭ 13 (-23.53%)
Mutual labels:  tiny
shivneri
Component based MVC web framework based on fort architecture targeting good code structures, modularity & performance.
Stars: ✭ 21 (+23.53%)
Mutual labels:  crystal-language
mit-phd-thesis
MIT Ph.D. Thesis in LaTeX
Stars: ✭ 52 (+205.88%)
Mutual labels:  mit
SSTMCSPGAAS
Stupidly Simple Tiny Minimal Coming Soon Page Generator As A Service
Stars: ✭ 23 (+35.29%)
Mutual labels:  tiny
secrets.clj
A library designed to generate cryptographically strong random numbers.
Stars: ✭ 64 (+276.47%)
Mutual labels:  uuid
loopback-component-migrate
Migration framework for loopback
Stars: ✭ 43 (+152.94%)
Mutual labels:  mit
ksuid-go
K-Sortable globally Unique ID
Stars: ✭ 15 (-11.76%)
Mutual labels:  uuid
zork
Full C++-17 port of the 616-point version of Zork from MIT circa 1978-1981
Stars: ✭ 16 (-5.88%)
Mutual labels:  mit
lectures and talks
Collection of lectures and talks I've given on Computer Vision and Deep Learning
Stars: ✭ 29 (+70.59%)
Mutual labels:  mit

uuix

A tiny (<1KB) and fast UUID (v4) generator for Crystal

This is the Crystal version of @lukeed/uuid

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      uuix:
        github: krthr/uuix
  2. Run shards install

Usage

require "uuix"

puts UUIX.random # bc524cd7-5ec3-48c4-9bcc-e9013c69dd6e

Benchmarks

Actual version:

Using String.build (to optimize string generation). Proposed by Sergey Kuznetsov in this thread

Crystal 1.1.1 [6d9a1d583] (2021-07-26)

LLVM: 10.0.1
Default target: x86_64-unknown-linux-gnu
        UUIX:   2.71M (368.51ns) (± 9.29%)  321B/op        fastest
Crystal UUID:   1.15M (867.45ns) (± 3.78%)  0.0B/op   2.35× slower

Original version:

Crystal 0.33.0 [612825a53] (2020-02-14)

LLVM: 8.0.0
Default target: x86_64-unknown-linux-gnu
        UUIX: 920.14k (  1.09µs) (± 9.68%)  880B/op        fastest
Crystal UUID: 647.32k (  1.54µs) (± 7.53%)  0.0B/op   1.42× slower

Performance

Taken from https://github.com/lukeed/uuid

The reason why this UUID.V4 implementation is so much faster is two-fold:

  1. It composes an output with hexadecimal pairs (from a cached dictionary) instead of single characters.
  2. It allocates a larger Buffer/ArrayBuffer up front (expensive) and slices off chunks as needed (cheap).

The internal ArrayBuffer is 4096 bytes, which supplies 256 random invocations.

A larger buffer would result in higher performance over time, but I found this to be a good balance of performance and memory space.

Contributing

  1. Fork it (https://github.com/krthr/uuix/fork)
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

  • krthr - creator and maintainer
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].