diff --git a/.tool-versions b/.tool-versions index 7b81f3f..ce0360e 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1,2 +1,2 @@ erlang 27.0.1 -elixir 1.17.2-otp-27 \ No newline at end of file +elixir 1.17.2-otp-27 diff --git a/README.md b/README.md index deac091..6288034 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,10 @@ # UUIDv7 -A UUID v7 implementation and `Ecto.Type` for Elixir. The RFC for the version 7 UUID: [RFC 9562](https://datatracker.ietf.org/doc/rfc9562/). This library includes an `Ecto.Type` to (auto-)generate version 7 UUIDs in `Ecto.Schema` and beyond. +A UUID v7 implementation and `Ecto.Type` for Elixir. + +The RFC for the version 7 UUID: [RFC 9562](https://datatracker.ietf.org/doc/rfc9562/). + +This library includes an `Ecto.Type` to (auto-)generate version 7 UUIDs in `Ecto.Schema` and beyond. ## Installation @@ -31,8 +35,9 @@ Operating System: macOS CPU Information: Apple M2 Pro Number of Available Cores: 10 Available memory: 16 GB -Elixir 1.14.2 -Erlang 25.1.2 +Elixir 1.17.2 +Erlang 27.0.1 +JIT enabled: true Benchmark suite executing with the following configuration: warmup: 5 s @@ -43,35 +48,25 @@ parallel: 1 inputs: none specified Estimated total run time: 1 min -Benchmarking ecto (uuid v4) ... -Benchmarking uniq (uuid v7) ... -Benchmarking uuidv7 ... - Name ips average deviation median 99th % -uuidv7 1.75 M 570.22 ns ±3940.19% 500 ns 667 ns -uniq (uuid v7) 1.07 M 937.20 ns ±1852.78% 916 ns 1000 ns -ecto (uuid v4) 1.02 M 978.17 ns ±1593.54% 958 ns 1042 ns +uuidv7 1.82 M 550.49 ns ±15102.40% 417 ns 1291 ns +uniq (uuid v7) 1.80 M 554.54 ns ±19362.74% 417 ns 1292 ns +ecto (uuid v4) 1.72 M 579.75 ns ±12640.39% 458 ns 1208 ns Comparison: -uuidv7 1.75 M -uniq (uuid v7) 1.07 M - 1.64x slower +366.98 ns -ecto (uuid v4) 1.02 M - 1.72x slower +407.95 ns +uuidv7 1.82 M +uniq (uuid v7) 1.80 M - 1.01x slower +4.05 ns +ecto (uuid v4) 1.72 M - 1.05x slower +29.25 ns Memory usage statistics: Name average deviation median 99th % -uuidv7 104 B ±0.00% 104 B 104 B -uniq (uuid v7) 214.00 B ±2.47% 216 B 216 B -ecto (uuid v4) 214.00 B ±2.47% 216 B 216 B +uuidv7 237.99 B ±2.23% 240 B 240 B +uniq (uuid v7) 214.01 B ±2.47% 216 B 216 B +ecto (uuid v4) 214.01 B ±2.47% 216 B 216 B Comparison: -uuidv7 104 B -uniq (uuid v7) 214.00 B - 2.06x memory usage +110.00 B -ecto (uuid v4) 214.00 B - 2.06x memory usage +110.00 B +uuidv7 240 B +uniq (uuid v7) 214.01 B - 0.90x memory usage -23.98508 B +ecto (uuid v4) 214.01 B - 0.90x memory usage -23.98596 B ``` - -## Credits - -This library is based on the Rust library [UUID](https://crates.io/crates/uuid). Thank you! - -The `Ecto.Type` is heavily borrowed from from [Ecto](https://github.com/elixir-ecto/ecto). Thanks! diff --git a/lib/uuidv7.ex b/lib/uuidv7.ex index 558191e..a84c899 100644 --- a/lib/uuidv7.ex +++ b/lib/uuidv7.ex @@ -1,6 +1,10 @@ defmodule UUIDv7 do @moduledoc """ - A UUID v7 implementation and `Ecto.Type` for Elixir + A UUID v7 implementation and `Ecto.Type` for Elixir. + + The RFC for the version 7 UUID: [RFC 9562](https://datatracker.ietf.org/doc/rfc9562/). + + This library includes an `Ecto.Type` to (auto-)generate version 7 UUIDs in `Ecto.Schema` and beyond. ## Installation @@ -8,7 +12,7 @@ defmodule UUIDv7 do ```elixir def deps do - [{:uuidv7, "~> 0.2"}] + [{:uuidv7, "~> 1.0"}] end ```