This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <vector> | |
| #include <uuid/uuid.h> | |
| int main() | |
| { | |
| std::vector<std::string> uuids; | |
| static const int BIGNUM = 1000; | |
| for (auto i = 0; i < BIGNUM; ++i) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <uuid/uuid.h> | |
| // This builds fine on both GNU/Linux (g++ 4.8, util-linux 2.23.2-33) | |
| // and macOS Sierra (clang-800.0.42.1). | |
| // | |
| // On GNU/Linux, libuuid is provided by util-linux; macOS seems to be | |
| // shipping things from e2fsprogs. | |
| // | |
| // No need of passing -luuid flag on macOS though. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <chrono> | |
| #include <iostream> | |
| #include <list> | |
| #include <mutex> | |
| #include <random> | |
| #include <sstream> | |
| #include <thread> | |
| static std::mutex g_mutex; | |
| static const int NUM_THREADS = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <chrono> | |
| #include <cstdlib> | |
| #include <iostream> | |
| #include <list> | |
| #include <mutex> | |
| #include <sstream> | |
| #include <thread> | |
| static std::mutex g_mutex; | |
| static const int NUM_THREADS = 10; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <iostream> | |
| #include <thread> | |
| #include <mutex> | |
| #include <chrono> | |
| #include <cstdlib> | |
| std::mutex g_mutex; | |
| void runner(int tid) | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RandomStr7 where | |
| -- Couple more random token generators based on `random` package. | |
| -- Do `:set +s` in ghci for quick timing checks. | |
| import Control.DeepSeq (force) | |
| import Control.Monad (replicateM, (>=>)) | |
| import Data.List (nub) | |
| import Data.Text (Text, pack) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# LANGUAGE PackageImports #-} | |
| module RandomStr6 where | |
| -- Uses `crypto-api` package, but with `newGenIO` rather than | |
| -- `newGen`; doesn't result in "*** Exception: NeedsInfiniteSeed" | |
| -- | |
| -- extension `PackageImports` is needed because `Crypto.Random` | |
| -- appears in `crypto-api`, `crypto-random`, and `cryptonite` | |
| -- packages. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RandomStr5 where | |
| -- uses `MonadRandom` package | |
| import Control.DeepSeq (force) | |
| import Control.Monad (liftM) | |
| import Control.Monad.Random (evalRandIO, getRandoms) | |
| import Data.List (nub) | |
| import Data.Text (Text, pack) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RandomStr4 where | |
| -- uses `random` package | |
| import Data.List as L | |
| import Data.Text as T | |
| import System.Random (RandomGen, newStdGen, randomRIO, randomRs) | |
| ------------------------------------------------------------------------ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module RandomStr3 where | |
| -- uses mwc-random for making random strings | |
| import Data.List (nub) | |
| import Data.Text as T (Text, pack) | |
| import qualified Data.Vector.Unboxed as V (Vector, map, toList) | |
| import Data.Word (Word8) | |
| import System.Random.MWC (asGenST, uniformVector, withSystemRandom) |