NAME
    Acme::CPANModules::UUID - Modules that can generate immutable
    universally unique identifier (UUIDs)

VERSION
    This document describes version 0.010 of Acme::CPANModules::UUID (from
    Perl distribution Acme-CPANModules-UUID), released on 2021-05-06.

SYNOPSIS
    To run benchmark with default option:

     % bencher --cpanmodules-module UUID

    To run module startup overhead benchmark:

     % bencher --module-startup --cpanmodules-module UUID

    For more options (dump scenario, list/include/exclude/add participants,
    list/include/exclude/add datasets, etc), see bencher or run "bencher
    --help".

DESCRIPTION
    UUIDs (Universally Unique Identifiers), sometimes also called GUIDs
    (Globally Unique Identifiers), are 128-bit numbers that can be used as
    permanent IDs or keys in databases. There are several standards that
    specify UUID, one of which is RFC 4122 (2005), which we will follow in
    this document.

    UUIDs are canonically represented as 32 hexadecimal digits in the form
    of:

     xxxxxxxx-xxxx-Mxxx-Nxxx-xxxxxxxxxxxx

    There are several variants of UUID. The variant information is encoded
    using 1-3 bits in the "N" position. RFC 4122 defines 4 variants (0 to
    3), two of which (0 and 3) are for legacy UUIDs, so that leaves variants
    1 and 2 as the current specification.

    There are 5 "versions" of UUID for both variants 1 & 2, each might be
    more suitable than others in specific cases. The version information is
    encoded in the M position. Version 1 (v1) UUIDs are generated from a
    time and a node ID (usually the MAC address); version 2 (v2) UUIDs from
    an identifier (group/user ID), a time, and a node ID; version 4 (v4)
    UUIDs from a rando/mpseudo-random number; version 3 (v3) UUIDs from
    hashing a namespace using MD5; version 5 (v5) from hashing a namespace
    using SHA-1.

    Data::UUID should be your first choice, and when you cannot install XS
    modules you can use UUID::Tiny instead.

    Aside from the modules listed as entries below, there are also:
    App::UUIDUtils (containing CLIs to create/check UUID), Data::GUID
    (currently just a wrapper for Data::UUID).

ACME::CPANMODULES ENTRIES
    *   Data::UUID

        This module creates v1 and v2 UUIDs. Depending on the OS, for MAC
        address, it usually uses a hash of hostname instead. This module is
        XS, so performance is good. If you cannot use an XS module, try
        UUID::Tiny instead.

        The benchmark code creates 1000+1 v1 string UUIDs.

    *   UUID::FFI

        This module provides access to libuuid via the FFI interface. It can
        create v1 as well as v4 (random) UUIDs. Note that Data::UUID
        (XS-based) is faster this module (FFI-based).

        The benchmark code creates 1000+1 v1 string UUIDs.

    *   UUID::Tiny

        This module should be your go-to choice if you cannot use an XS
        module. It can create v1, v3, v4 UUIDs. However, the random v4 UUIDs
        are not cryptographically secure; if you need cryptographically
        secure random UUIDs, use Crypt::Misc.

        The benchmark code creates 1000+1 v1 string UUIDs.

        See also: Types::UUID which is a type library that uses Data::UUID
        as the backend.

    *   UUID::Random

        This module simply uses 32 calls to Perl's "rand()" to construct
        each random hexadecimal digits of the UUID (v4). Not really
        recommended, since perl's default pseudo-random generator is neither
        cryptographically secure nor has 128 bit of entropy. It also does
        not produce v4 UUIDs that conform to RFC 4122 (no encoding of
        variant & version information).

        To create a cryptographically secure random UUIDs, use Crypt::Misc.

        The benchmark code creates 1000+1 v4 string UUIDs.

    *   UUID::Random::PERLANCAR

        Just another implementation of UUID::Random.

        The benchmark code creates 1000+1 v4 string UUIDs.

    *   UUID::Random::Secure

        Just like UUID::Random, except it uses Math::Random::Secure's
        "irand()" to produce random numbers.

        The benchmark code creates 1000+1 v4 string UUIDs.

    *   Crypt::Misc

        This module from the CryptX distribution has a function to create
        and check v4 UUIDs.

        The benchmark code creates 1000+1 v4 string UUIDs.

ACME::CPANMODULES FEATURE COMPARISON MATRIX
     +-------------------------+-----------+-----------+-----------+-----------+-----------+-------+-------+----------------+----------------------+
     | module                  | create_v1 | create_v2 | create_v3 | create_v4 | create_v5 | is_pp | is_xs | v4_rfc4122 *1) | v4_secure_random *2) |
     +-------------------------+-----------+-----------+-----------+-----------+-----------+-------+-------+----------------+----------------------+
     | Data::UUID              | yes       | yes       | no        | no        | no        | no    | yes   | N/A            | N/A                  |
     | UUID::FFI               | yes       | no        | no        | yes       | no        | no    | yes   | yes            | no                   |
     | UUID::Tiny              | yes       | no        | yes       | yes       | yes       | yes   | no    | yes            | no                   |
     | UUID::Random            | no        | no        | no        | yes       | no        | yes   | no    | no             | no                   |
     | UUID::Random::PERLANCAR | no        | no        | no        | yes       | no        | yes   | no    | yes            | no                   |
     | UUID::Random::Secure    | no        | no        | no        | yes       | no        | yes   | no    | yes            | yes                  |
     | Crypt::Misc             | no        | no        | no        | yes       | no        | yes   | no    | yes            | yes                  |
     +-------------------------+-----------+-----------+-----------+-----------+-----------+-------+-------+----------------+----------------------+

    Notes:

    1. v4_rfc4122: Whether the generated v4 UUID follows RFC 4122
    specification (i.e. encodes variant and version information in M & N
    positions)
    2. v4_secure_random: Whether the module uses cryptographically secure
    pseudo-random number generator for v4 UUIDs

BENCHMARKED MODULES
    Version numbers shown below are the versions used when running the
    sample benchmark.

    Data::UUID 1.224

    UUID::FFI 0.09

    UUID::Tiny 1.04

    UUID::Random 0.04

    UUID::Random::PERLANCAR 0.005

    UUID::Random::Secure 0.004

    Crypt::Misc 0.069

BENCHMARK PARTICIPANTS
    *   Data::UUID (perl_code)

        Code template:

         my $u = Data::UUID->new; $u->create for 1..1000; $u->to_string($u->create)

    *   UUID::FFI (perl_code)

        Code template:

         UUID::FFI->new_time for 1..1000; UUID::FFI->new_time->as_hex

    *   UUID::Tiny (perl_code)

        Code template:

         UUID::Tiny::create_uuid() for 1..1000; UUID::Tiny::uuid_to_string(UUID::Tiny::create_uuid())

    *   UUID::Random (perl_code)

        Code template:

         UUID::Random::generate() for 1..1000; ; UUID::Random::generate()

    *   UUID::Random::PERLANCAR::generate (perl_code)

        Code template:

         UUID::Random::PERLANCAR::generate() for 1..1000; UUID::Random::PERLANCAR::generate()

    *   UUID::Random::PERLANCAR::generate_rfc (perl_code)

        Code template:

         UUID::Random::PERLANCAR::generate_rfc() for 1..1000; UUID::Random::PERLANCAR::generate_rfc()

    *   UUID::Random::Secure::generate (perl_code)

        Code template:

         UUID::Random::Secure::generate() for 1..1000; UUID::Random::Secure::generate()

    *   UUID::Random::Secure::generate_rfc (perl_code)

        Code template:

         UUID::Random::Secure::generate_rfc() for 1..1000; UUID::Random::Secure::generate_rfc()

    *   Crypt::Misc (perl_code)

        Code template:

         Crypt::Misc::random_v4uuid() for 1..1000; Crypt::Misc::random_v4uuid()

SAMPLE BENCHMARK RESULTS
    Run on: perl: *v5.30.0*, CPU: *Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
    (2 cores)*, OS: *GNU/Linux Ubuntu version 20.04*, OS kernel: *Linux
    version 5.3.0-64-generic*.

    Benchmark with default options ("bencher --cpanmodules-module UUID"):

     #table1#
     +---------------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+
     | participant                           | rate (/s) | time (ms) | pct_faster_vs_slowest | pct_slower_vs_fastest |  errors   | samples |
     +---------------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+
     | UUID::Random::Secure::generate_rfc    |        46 |     22    |                 0.00% |              4868.44% | 7.5e-05   |      28 |
     | UUID::Random::Secure::generate        |        47 |     21    |                 2.74% |              4735.97% |   6e-05   |      23 |
     | UUID::Random                          |        90 |     10    |                95.80% |              2437.45% |   0.00034 |      22 |
     | UUID::Tiny                            |       140 |      7.2  |               201.89% |              1545.81% | 1.8e-05   |      20 |
     | Crypt::Misc                           |       290 |      3.5  |               525.12% |               694.80% | 1.4e-05   |      20 |
     | UUID::FFI                             |       930 |      1.1  |              1911.64% |               146.98% | 3.4e-06   |      20 |
     | UUID::Random::PERLANCAR::generate_rfc |      1000 |      1    |              2098.91% |               125.95% | 2.9e-05   |      34 |
     | UUID::Random::PERLANCAR::generate     |      1700 |      0.59 |              3596.91% |                34.39% | 1.1e-06   |      20 |
     | Data::UUID                            |      2300 |      0.44 |              4868.44% |                 0.00% | 1.8e-06   |      20 |
     +---------------------------------------+-----------+-----------+-----------------------+-----------------------+-----------+---------+

    Benchmark module startup overhead ("bencher --cpanmodules-module UUID
    --module-startup"):

     #table2#
     +-------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+
     | participant             | time (ms) | mod_overhead_time | pct_faster_vs_slowest | pct_slower_vs_fastest |  errors   | samples |
     +-------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+
     | UUID::Random::Secure    |      86   |              78   |                 0.00% |               976.54% |   0.00038 |      20 |
     | UUID::FFI               |      60   |              52   |                44.16% |               646.77% | 8.1e-05   |      20 |
     | UUID::Tiny              |      24   |              16   |               259.84% |               199.17% | 3.8e-05   |      22 |
     | Crypt::Misc             |      18.3 |              10.3 |               371.86% |               128.15% | 1.6e-05   |      20 |
     | Data::UUID              |      16   |               8   |               429.19% |               103.43% |   0.00012 |      20 |
     | UUID::Random            |       9.2 |               1.2 |               840.25% |                14.50% | 2.7e-05   |      20 |
     | UUID::Random::PERLANCAR |       9.1 |               1.1 |               850.03% |                13.32% | 2.3e-05   |      20 |
     | perl -e1 (baseline)     |       8   |               0   |               976.54% |                 0.00% |   0.00018 |      20 |
     +-------------------------+-----------+-------------------+-----------------------+-----------------------+-----------+---------+

    To display as an interactive HTML table on a browser, you can add option
    "--format html+datatables".

FAQ
  What is an Acme::CPANModules::* module?
    An Acme::CPANModules::* module, like this module, contains just a list
    of module names that share a common characteristics. It is a way to
    categorize modules and document CPAN. See Acme::CPANModules for more
    details.

  What are ways to use this Acme::CPANModules module?
    Aside from reading this Acme::CPANModules module's POD documentation,
    you can install all the listed modules (entries) using cpanmodules CLI
    (from App::cpanmodules distribution):

        % cpanmodules ls-entries UUID | cpanm -n

    or Acme::CM::Get:

        % perl -MAcme::CM::Get=UUID -E'say $_->{module} for @{ $LIST->{entries} }' | cpanm -n

    or directly:

        % perl -MAcme::CPANModules::UUID -E'say $_->{module} for @{ $Acme::CPANModules::UUID::LIST->{entries} }' | cpanm -n

    This Acme::CPANModules module contains benchmark instructions. You can
    run a benchmark for some/all the modules listed in this
    Acme::CPANModules module using the bencher CLI (from Bencher
    distribution):

        % bencher --cpanmodules-module UUID

    This Acme::CPANModules module also helps lcpan produce a more meaningful
    result for "lcpan related-mods" command when it comes to finding related
    modules for the modules listed in this Acme::CPANModules module.

HOMEPAGE
    Please visit the project's homepage at
    <https://metacpan.org/release/Acme-CPANModules-UUID>.

SOURCE
    Source repository is at
    <https://github.com/perlancar/perl-Acme-CPANModules-UUID>.

BUGS
    Please report any bugs or feature requests on the bugtracker website
    <https://github.com/perlancar/perl-Acme-CPANModules-UUID/issues>

    When submitting a bug or request, please include a test-file or a patch
    to an existing test-file that illustrates the bug or desired feature.

SEE ALSO
    Acme::CPANModules - about the Acme::CPANModules namespace

    cpanmodules - CLI tool to let you browse/view the lists

    RFC 4122, <https://tools.ietf.org/html/rfc4122>

AUTHOR
    perlancar <perlancar@cpan.org>

COPYRIGHT AND LICENSE
    This software is copyright (c) 2021, 2020 by perlancar@cpan.org.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.