diff --git a/CHANGELOG/CHANGELOG-1.x.md b/CHANGELOG/CHANGELOG-1.x.md index 3385511..22eb41c 100644 --- a/CHANGELOG/CHANGELOG-1.x.md +++ b/CHANGELOG/CHANGELOG-1.x.md @@ -15,12 +15,23 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security +--- +## [1.9.0] - 2024-NOV-01 + +### Added +- **FEATURE:** Added new `MustGenerate` and `MustGenerateSize` functions to simplifies safe initialization of global variables. +### Changed +### Deprecated +### Removed +### Fixed +### Security + --- ## [1.8.2] - 2024-OCT-31 ### Added ### Changed -- **RISK:** risk: Excluded docs and scripts from SonarCloud analysis. +- **RISK:** Excluded docs and scripts from SonarCloud analysis. ### Deprecated ### Removed ### Fixed @@ -169,7 +180,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed ### Security -[Unreleased]: https://github.com/scriptures-social/platform/compare/v1.8.2...HEAD +[Unreleased]: https://github.com/scriptures-social/platform/compare/v1.9.0...HEAD +[1.9.0]: https://github.com/sixafter/nanoid/compare/v1.8.2...v1.9.0 [1.8.2]: https://github.com/sixafter/nanoid/compare/v1.8.1...v1.8.2 [1.8.1]: https://github.com/sixafter/nanoid/compare/v1.8.0...v1.8.1 [1.8.0]: https://github.com/sixafter/nanoid/compare/v1.7.1...v1.8.0 diff --git a/README.md b/README.md index ceef1d5..fa98b9f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ A simple, fast, and efficient Go implementation of [Nano ID](https://github.com/ - **Short & Unique IDs**: Generates compact and collision-resistant identifiers. - **Cryptographically Secure**: Utilizes Go's `crypto/rand` package for generating cryptographically secure random numbers. This guarantees that the generated IDs are both unpredictable and suitable for security-sensitive applications. -- **Customizable Alphabet**: Define your own set of characters for ID generation with a minimum length of 2 characters and a maximum length of 256 characters. +- **Customizable Alphabet**: Define your own set of characters for ID generation with a minimum length of 2 characters. ASCII and Unicode are supported with optimizations for both. - **Concurrency Safe**: Designed to be safe for use in concurrent environments. - **High Performance**: Optimized with buffer pooling to minimize allocations and enhance speed. - **Zero Dependencies**: Lightweight implementation with no external dependencies beyond the standard library. @@ -235,188 +235,188 @@ goos: darwin goarch: arm64 pkg: github.com/sixafter/nanoid cpu: Apple M2 Ultra -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen8-24 10418562 112.0 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen16-24 4204862 285.5 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen21-24 3918693 300.2 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen32-24 3727174 320.9 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen64-24 3060626 394.0 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen128-24 2374159 510.1 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen8-24 10628976 111.4 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen16-24 4227380 282.1 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen21-24 3992378 298.6 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen32-24 3762184 321.3 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen64-24 3111062 388.3 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen128-24 2363734 508.1 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen8-24 10828202 111.9 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen16-24 4188156 283.9 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen21-24 3966552 303.5 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen32-24 3707356 322.4 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen64-24 3077642 387.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen128-24 2336438 511.8 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen8-24 10687689 111.7 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen16-24 4226514 285.5 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen21-24 3965374 301.0 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen32-24 3736278 324.5 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen64-24 3092551 389.6 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen128-24 2357520 511.1 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen8-24 4711828 244.9 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen16-24 2522955 474.6 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen21-24 2315516 522.8 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen32-24 1949098 611.5 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen64-24 1298616 924.2 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen128-24 867211 1302 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen8-24 7062561 168.3 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen16-24 3112558 386.9 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen21-24 2668669 454.0 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen32-24 2235410 536.7 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen64-24 1511804 793.0 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen128-24 906760 1310 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen8-24 7125273 167.1 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen16-24 3106981 386.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen21-24 2668101 461.7 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen32-24 2137002 547.6 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen64-24 1461828 814.4 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen128-24 915102 1305 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen8-24 7122510 168.9 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen16-24 3027632 387.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen21-24 2683312 455.6 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen32-24 2228652 556.0 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen64-24 1491031 819.2 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen128-24 852464 1336 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen8-24 4579814 260.9 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen16-24 2259762 531.3 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen21-24 1923090 613.0 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen32-24 1582443 730.3 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen64-24 1000000 1133 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen128-24 661370 1839 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen8-24 4731512 262.3 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen16-24 2314345 517.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen21-24 1994914 632.7 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen32-24 1667074 731.3 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen64-24 1000000 1156 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen128-24 645205 1859 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen8-24 3147912 388.2 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen16-24 1486123 825.3 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen21-24 1423960 856.0 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen32-24 1368358 882.1 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen64-24 1216256 973.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen128-24 1000000 1118 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen8-24 3216572 378.5 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen16-24 1485900 806.6 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen21-24 1424578 849.5 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen32-24 1335081 898.2 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen64-24 1000000 1007 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen128-24 1000000 1116 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen8-24 3188726 381.6 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen16-24 1414419 819.0 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen21-24 1418808 848.9 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen32-24 1368144 873.1 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen64-24 1219441 982.9 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen128-24 1000000 1107 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen8-24 3159601 405.4 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen16-24 1455963 822.9 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen21-24 1433679 846.8 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen32-24 1381220 868.7 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen64-24 1233231 972.9 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen128-24 1000000 1096 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen8-24 1428054 853.0 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen16-24 826676 1533 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen21-24 627172 1639 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen32-24 640642 1897 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen64-24 457977 2681 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen128-24 358770 3325 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen8-24 2435527 488.0 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen16-24 1252327 969.7 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen21-24 1000000 1038 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen32-24 1000000 1097 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen64-24 962730 1289 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen128-24 801014 1557 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen8-24 2310380 497.8 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen16-24 1237915 964.7 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen21-24 1000000 1035 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen32-24 1000000 1112 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen64-24 946850 1292 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen128-24 740536 1575 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen8-24 2343194 490.4 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen16-24 1230936 976.6 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen21-24 1000000 1055 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen32-24 996325 1109 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen64-24 927045 1307 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen128-24 779859 1593 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen8-24 1470223 819.3 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen16-24 795807 1599 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen21-24 684703 1769 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen32-24 598116 1954 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen64-24 437926 2692 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen128-24 327703 3785 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen8-24 1405555 834.5 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen16-24 794175 1544 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen21-24 735001 1713 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen32-24 592226 1979 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen64-24 424042 2704 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen128-24 325590 3664 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen8-24 10442265 115.0 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen16-24 4181119 291.2 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen21-24 3898227 311.7 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen32-24 3632714 330.8 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen64-24 2956627 393.8 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen128-24 2286168 525.7 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen8-24 10668045 113.3 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen16-24 4166764 289.0 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen21-24 3870742 308.9 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen32-24 3677217 336.9 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen64-24 3017631 406.2 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen128-24 2226591 531.6 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen8-24 10315075 115.2 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen16-24 4191613 286.0 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen21-24 3999072 301.8 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen32-24 3673783 328.5 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen64-24 3013660 396.5 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen128-24 2289802 532.2 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen8-24 9420152 113.2 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen16-24 4086746 293.2 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen21-24 3830166 305.7 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen32-24 3693453 322.8 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen64-24 3044371 395.5 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen128-24 2283253 523.1 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen8-24 4883360 244.7 ns/op 16 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen16-24 2472624 483.5 ns/op 32 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen21-24 2276542 525.8 ns/op 48 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen32-24 1956292 623.2 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen64-24 1298796 922.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen128-24 900985 1304 ns/op 256 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen8-24 7071021 168.3 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen16-24 3074877 393.0 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen21-24 2647694 449.9 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen32-24 2217471 539.5 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen64-24 1481122 808.4 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen128-24 897288 1332 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen8-24 7013146 168.5 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen16-24 3052245 386.4 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen21-24 2607384 465.8 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen32-24 2112885 569.2 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen64-24 1471886 819.8 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen128-24 858808 1361 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen8-24 6907552 170.9 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen16-24 3003462 397.9 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen21-24 2593538 460.8 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen32-24 2201772 544.7 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen64-24 1487638 809.3 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen128-24 876087 1354 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen8-24 4592804 256.8 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen16-24 2244604 540.0 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen21-24 1947669 617.4 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen32-24 1645828 724.3 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen64-24 1000000 1134 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen128-24 638697 1861 ns/op 929 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen8-24 4711143 253.8 ns/op 64 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen16-24 2332794 523.6 ns/op 128 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen21-24 1989870 613.6 ns/op 176 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen32-24 1664764 728.9 ns/op 240 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen64-24 1000000 1138 ns/op 464 B/op 2 allocs/op -BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen128-24 625184 1910 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen8-24 9900825 119.0 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen16-24 3839343 310.7 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen21-24 3697426 324.9 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen32-24 3403065 355.0 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen64-24 2721128 443.3 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen2/IDLen128-24 1986505 611.1 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen8-24 9938446 119.8 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen16-24 3804894 310.2 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen21-24 3759706 318.6 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen32-24 3507075 343.9 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen64-24 2773866 429.3 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen16/IDLen128-24 2020968 591.2 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen8-24 10467040 116.9 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen16-24 3967908 303.9 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen21-24 3671436 317.6 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen32-24 3470918 345.6 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen64-24 2795991 430.5 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen32/IDLen128-24 2038209 591.9 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen8-24 10072525 116.4 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen16-24 3944463 304.5 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen21-24 3778465 329.4 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen32-24 3322444 346.5 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen64-24 2778516 430.6 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen64/IDLen128-24 2024299 588.7 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen8-24 4929242 245.0 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen16-24 2445019 489.8 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen21-24 2239215 533.0 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen32-24 1903724 624.6 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen64-24 1246633 964.2 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/ASCII_AlphabetLen95/IDLen128-24 880270 1365 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen8-24 7129393 166.6 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen16-24 3088347 387.2 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen21-24 2676687 447.5 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen32-24 2260320 529.4 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen64-24 1503513 775.8 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen2/IDLen128-24 918639 1273 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen8-24 7141119 167.6 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen16-24 3094470 390.4 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen21-24 2659474 449.6 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen32-24 2250259 533.7 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen64-24 1525422 778.6 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen16/IDLen128-24 939098 1275 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen8-24 7075434 168.0 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen16-24 3078884 390.8 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen21-24 2653651 450.8 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen32-24 2250336 534.3 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen64-24 1535886 779.7 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen32/IDLen128-24 905656 1273 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen8-24 4705986 254.1 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen16-24 2362225 511.0 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen21-24 2024662 589.0 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen32-24 1689366 705.7 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen64-24 1000000 1098 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen64/IDLen128-24 647395 1781 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen8-24 4692651 251.9 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen16-24 2358103 510.5 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen21-24 2025705 591.0 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen32-24 1684885 707.9 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen64-24 1000000 1102 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGeneration/Unicode_AlphabetLen95/IDLen128-24 642933 1797 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen8-24 2989003 390.5 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen16-24 1466362 825.1 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen21-24 1404768 857.2 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen32-24 1333918 920.0 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen64-24 1000000 1026 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen2/IDLen128-24 1000000 1152 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen8-24 3085243 396.0 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen16-24 1466227 825.1 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen21-24 1410675 851.8 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen32-24 1333658 897.7 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen64-24 1000000 1018 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen16/IDLen128-24 1000000 1149 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen8-24 3039732 394.5 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen16-24 1443295 821.3 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen21-24 1413276 852.6 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen32-24 1332478 914.1 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen64-24 1000000 1029 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen32/IDLen128-24 1000000 1155 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen8-24 3071056 390.1 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen16-24 1457083 826.4 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen21-24 1398894 849.8 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen32-24 1346475 886.5 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen64-24 1000000 1026 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen64/IDLen128-24 1000000 1142 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen8-24 1430025 834.6 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen16-24 740119 1543 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen21-24 671708 1677 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen32-24 605883 1925 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen64-24 443612 2725 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/ASCII_AlphabetLen95/IDLen128-24 344932 3489 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen8-24 2391144 500.5 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen16-24 1237058 966.6 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen21-24 1000000 1044 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen32-24 985527 1120 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen64-24 954957 1294 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen2/IDLen128-24 727497 1577 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen8-24 2411503 498.8 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen16-24 1225498 969.1 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen21-24 1000000 1041 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen32-24 1000000 1118 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen64-24 884580 1299 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen16/IDLen128-24 734211 1596 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen8-24 2419585 497.5 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen16-24 1240014 974.8 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen21-24 1000000 1037 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen32-24 1000000 1114 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen64-24 946449 1307 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen32/IDLen128-24 719616 1600 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen8-24 1448635 831.5 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen16-24 885998 1527 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen21-24 702578 1714 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen32-24 600270 1952 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen64-24 443122 2687 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen64/IDLen128-24 329334 3664 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen8-24 1452666 827.1 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen16-24 785490 1506 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen21-24 704905 1707 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen32-24 608680 1966 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen64-24 453290 2708 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDGenerationParallel/Unicode_AlphabetLen95/IDLen128-24 322802 3677 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen8-24 10134021 116.7 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen16-24 3946090 305.3 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen21-24 3794966 313.8 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen32-24 3502370 339.8 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen64-24 2760170 434.3 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen2/IDLen128-24 1978986 604.9 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen8-24 10140744 117.2 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen16-24 3913432 306.8 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen21-24 3650574 325.3 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen32-24 3444016 344.2 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen64-24 2784463 438.6 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen16/IDLen128-24 1968044 625.7 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen8-24 9712027 119.9 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen16-24 3830364 314.2 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen21-24 3632488 334.7 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen32-24 3422242 345.7 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen64-24 2769238 433.6 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen32/IDLen128-24 1976390 604.3 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen8-24 10145660 116.9 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen16-24 3978235 303.7 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen21-24 3778012 318.5 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen32-24 3502041 344.3 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen64-24 2775818 431.4 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen64/IDLen128-24 1977230 603.6 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen8-24 4833774 247.3 ns/op 16 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen16-24 2449020 491.1 ns/op 32 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen21-24 2243475 537.2 ns/op 48 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen32-24 1885855 632.9 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen64-24 1235704 973.9 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/ASCII_AlphabetLen95/IDLen128-24 900153 1364 ns/op 256 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen8-24 7047174 170.0 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen16-24 3047263 390.7 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen21-24 2634684 461.1 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen32-24 2223579 541.8 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen64-24 1492694 801.0 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen2/IDLen128-24 906471 1319 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen8-24 6993999 169.6 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen16-24 3055308 390.0 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen21-24 2628690 454.6 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen32-24 2230983 540.8 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen64-24 1488814 799.8 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen16/IDLen128-24 897660 1327 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen8-24 7030861 171.7 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen16-24 3014774 391.2 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen21-24 2646554 457.6 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen32-24 2230081 539.6 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen64-24 1493530 802.2 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen32/IDLen128-24 924261 1326 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen8-24 4675761 258.1 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen16-24 2298976 524.4 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen21-24 2016050 592.8 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen32-24 1683283 712.1 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen64-24 1000000 1139 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen64/IDLen128-24 624578 1836 ns/op 929 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen8-24 4680818 253.9 ns/op 64 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen16-24 2349648 515.3 ns/op 128 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen21-24 2006119 596.1 ns/op 176 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen32-24 1638229 731.4 ns/op 240 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen64-24 1000000 1135 ns/op 464 B/op 2 allocs/op +BenchmarkNanoIDWithVaryingAlphabetLengths/Unicode_AlphabetLen95/IDLen128-24 636212 1885 ns/op 929 B/op 2 allocs/op PASS -ok github.com/sixafter/nanoid 282.115s +ok github.com/sixafter/nanoid 279.780s ``` diff --git a/nanoid.go b/nanoid.go index f1564aa..fa2b1fa 100644 --- a/nanoid.go +++ b/nanoid.go @@ -24,11 +24,35 @@ func Generate() (string, error) { return DefaultGenerator.Generate(DefaultSize) } +// MustGenerate generates a Nano ID using the default generator and the default size if err +// is nil or panics otherwise. +// It simplifies safe initialization of global variables holding compiled UUIDs. +func MustGenerate() string { + id, err := DefaultGenerator.Generate(DefaultSize) + if err != nil { + panic(err) + } + + return id +} + // GenerateSize generates a Nano ID using the default generator with a specified size. func GenerateSize(length int) (string, error) { return DefaultGenerator.Generate(length) } +// MustGenerateSize generates a Nano ID using the default generator with a specified size if err +// is nil or panics otherwise. +// It simplifies safe initialization of global variables holding compiled UUIDs. +func MustGenerateSize(length int) string { + id, err := DefaultGenerator.Generate(length) + if err != nil { + panic(err) + } + + return id +} + func init() { var err error DefaultGenerator, err = New(DefaultAlphabet, nil) @@ -61,6 +85,7 @@ const bufferMultiplier = 128 // Generator defines the interface for generating Nano IDs. type Generator interface { Generate(size int) (string, error) + MustGenerate(length int) string } // Configuration defines the interface for retrieving generator configuration. @@ -304,6 +329,17 @@ func (g *generator) Generate(length int) (string, error) { return string(id.([]rune)), nil } +// MustGenerate returns creates a new Nano ID of the specified length if err +// is nil or panics otherwise. +// It simplifies safe initialization of global variables holding compiled UUIDs. +func (g *generator) MustGenerate(length int) string { + id, err := g.Generate(length) + if err != nil { + panic(err) + } + return id +} + // GetConfig returns the configuration for the generator. // It implements the Configuration interface. func (g *generator) GetConfig() Config { diff --git a/nanoid_test.go b/nanoid_test.go index 4f20197..e8b02ea 100644 --- a/nanoid_test.go +++ b/nanoid_test.go @@ -47,6 +47,48 @@ func TestGenerateCustomLength(t *testing.T) { } } +// TestMustGenerateDefault tests the must generation of a default Nano ID. +func TestMustGenerateDefault(t *testing.T) { + t.Parallel() + is := assert.New(t) + + id := MustGenerate() + is.Equal(DefaultSize, len([]rune(id)), "Generated ID should have the default length") + + is.True(isValidID(id, DefaultAlphabet), "Generated ID contains invalid characters") +} + +// TestMustGenerateSize tests the must generation of Nano IDs with a custom length. +func TestMustGenerateSize(t *testing.T) { + t.Parallel() + is := assert.New(t) + + id := MustGenerateSize(DefaultSize) + is.Equal(DefaultSize, len([]rune(id)), "Generated ID should have the default length") + + is.True(isValidID(id, DefaultAlphabet), "Generated ID contains invalid characters") +} + +// TestMustGenerate tests the must generation of Nano IDs with custom lengths. +func TestMustGenerate(t *testing.T) { + lengths := []int{1, 5, 10, 21, 50, 100} + + gen, _ := New(DefaultAlphabet, nil) + + for _, length := range lengths { + length := length // capture range variable + t.Run("Length_"+strconv.Itoa(length), func(t *testing.T) { + t.Parallel() + is := assert.New(t) + + id := gen.MustGenerate(length) + is.Equal(length, len([]rune(id)), "Generated ID should have the specified length") + + is.True(isValidID(id, DefaultAlphabet), "Generated ID contains invalid characters") + }) + } +} + // TestGenerateInvalidLength tests the generator's response to invalid lengths. func TestGenerateInvalidLength(t *testing.T) { t.Parallel()