{"id":17335722,"url":"https://github.com/fufuok/random","last_synced_at":"2025-03-27T07:22:59.539Z","repository":{"id":112342630,"uuid":"418980649","full_name":"fufuok/random","owner":"fufuok","description":"🚀 Faster-random  Goroutine-safe, Faster pseudo-random number and string generator.","archived":false,"fork":false,"pushed_at":"2021-10-20T02:06:02.000Z","size":6,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-01T12:25:53.648Z","etag":null,"topics":["fastrandom"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fufuok.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-19T15:20:53.000Z","updated_at":"2022-04-24T04:51:45.000Z","dependencies_parsed_at":"2023-05-13T13:30:17.204Z","dependency_job_id":null,"html_url":"https://github.com/fufuok/random","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fufuok%2Frandom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fufuok%2Frandom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fufuok%2Frandom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fufuok%2Frandom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fufuok","download_url":"https://codeload.github.com/fufuok/random/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245798739,"owners_count":20674015,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fastrandom"],"created_at":"2024-10-15T15:11:58.218Z","updated_at":"2025-03-27T07:22:59.521Z","avatar_url":"https://github.com/fufuok.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Faster-random\n\nGoroutine-safe, Faster pseudo-random number and string generator.\n\n- Non-goroutine-safe: `var Random = rand.New(rand.NewSource(time.Now().UnixNano()))`\n- Goroutine-safe: `var Random = NewRand()`, and has super high performance. See: [Benchmarks](#-benchmarks).\n\n## ⚙️ Installation\n\n```go\ngo get -u github.com/fufuok/random\n```\n\n## ⚡️ Quickstart\n\n```go\npackage main\n\nimport (\n\t\"fmt\"\n\n\t\"github.com/fufuok/random\"\n)\n\nfunc main() {\n\t// random.Rand is a goroutine-safe rand.New() instance\n\t// FastIntn similar to rand.Intn or random.Rand.Intn, but faster.\n\tfor i := 1; i \u003c= 1000000; i *= 10 {\n\t\tfmt.Print(random.Rand.Intn(i), random.FastIntn(i), \" \")\n\t}\n\n\tfmt.Println()\n\n\t// Fast random string generator\n\tfmt.Println(random.RandString(20), random.RandString(20))\n\n\t// Instantiate *rand.Rand with the current time by default\n\trd := random.NewRand()\n\tfmt.Println(rd.Int63())\n\n\t// Returns a new pseudo-random generator seeded with the given value.\n\trd = random.NewRand(1)\n\tfmt.Println(rd.Int63())\n}\n```\n\n## 📚 Examples\n\nplease see: [examples](examples)\n\n```go\npackage random // import \"github.com/fufuok/random\"\n\nvar Rand = NewRand()\nfunc FastIntn(n int) int\nfunc FastRand() uint32\nfunc FastRandBytes(n int) []byte\nfunc FastRandn(n uint32) uint32\nfunc NewRand(seed ...int64) *rand.Rand\nfunc RandBytes(n int) []byte\nfunc RandHex(nHalf int) string\nfunc RandInt(min, max int) int\nfunc RandString(n int) string\nfunc RandUint32(min, max uint32) uint32\n```\n\n## 🤖 Benchmarks\n\n```shell\ngo test -run=^$ -benchmem -benchtime=1s -count=2 -bench=.\ngoos: linux\ngoarch: amd64\npkg: github.com/fufuok/random\ncpu: Intel(R) Xeon(R) Gold 6151 CPU @ 3.00GHz\nBenchmarkRandInt/RandInt-4                     300554511                3.982 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/RandInt-4                     299879216                4.007 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/RandUint32-4                  266118160                4.466 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/RandUint32-4                  266337582                4.507 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/FastIntn-4                    313761758                3.834 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/FastIntn-4                    312968804                3.811 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/Rand.Intn-4                    35001715                34.30 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/Rand.Intn-4                    34904052                34.54 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/std.rand.Intn-4                56418733                21.57 ns/op            0 B/op          0 allocs/op\nBenchmarkRandInt/std.rand.Intn-4                56331698                21.41 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/RandInt-4            1000000000                1.060 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/RandInt-4            1000000000                1.045 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/RandUint32-4          990860647                1.197 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/RandUint32-4         1000000000                1.182 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/FastIntn-4           1000000000                1.060 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/FastIntn-4           1000000000                1.055 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/Rand.Intn-4           130758892                9.132 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/Rand.Intn-4           130173494                9.065 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/std.rand.Intn-4        13878208                88.73 ns/op            0 B/op          0 allocs/op\nBenchmarkRandIntParallel/std.rand.Intn-4        13828624                89.97 ns/op            0 B/op          0 allocs/op\n\nBenchmarkRandBytes/RandString-4                 18142927                64.27 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytes/RandString-4                 18944168                64.43 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytes/RandBytes-4                   1730853                694.3 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytes/RandBytes-4                   1719566                687.4 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytes/FastRandBytes-4              18185881                64.99 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytes/FastRandBytes-4              18052567                65.73 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/RandString-4         63093751                19.00 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/RandString-4         67928510                19.29 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/RandBytes-4           1309642                916.2 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/RandBytes-4           1315711                916.6 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/FastRandBytes-4      64837544                20.05 ns/op           24 B/op          1 allocs/op\nBenchmarkRandBytesParallel/FastRandBytes-4      65973478                19.52 ns/op           24 B/op          1 allocs/op\n```\n\n\n\n\n\n*ff*","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffufuok%2Frandom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffufuok%2Frandom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffufuok%2Frandom/lists"}