Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

pcg_random

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pcg_random

  • 0.1.6
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

PCGRandom

Gem Version

 _____ _____ _____ _____           _           
|  _  |     |   __| __  |___ ___ _| |___ _____ 
|   __|   --|  |  |    -| .'|   | . | . |     |
|__|  |_____|_____|__|__|__,|_|_|___|___|_|_|_|

Ruby wrappers for the PCGRandom family of random number generators.

Installation

Prerequisites

  • A C-compiler (any modern C compiler is supported on *nix, Windows isn't supported yet)
  • Modified C source code for pcg_random available here for building libpcg_random.
  • Follow the build instructions given here to build libpcg_random

Installing the gem:

  • Rubygems:
gem install pcg_random

You can also configure the path to libpcg_random by specifying it's path explicitly:

# specify the custome include path
gem install pcg_random --with-pcg_random-include=directory/containing/pcg_variants.h

# or, specify the custom path to the libpcg_random binary
gem install pcg_random --with-pcg_random-lib=directory/containing/libpcg_random.a

# Or, specify both the lib/ and include/ together to be under path/to/some/directory
gem install pcg_random --with-pcg_random-dir=path/to/some/directory

Development

TODO: Create a CONTRIBTING.md

Install pcg_random from source using the above steps. Using the above links are important because the library must be compiled with additional flags to be used for gem-development. There are also some issues in the original repository that are addressed in my fork.

Using the extension

Either jump into your REPL of choice:

~$ irb
2.3.0 :001 > require 'pcg_random'
 => true

Or go ahead and try the API, it's built to be as close to Kernel::Random as possible!

2.3.0 :002 > seed = PCGRanom.new_seed
 => 315431527813695542666700950080169144774
2.3.0 :003 > rng = PCGRanom.new 1234
 => #<PCGRandom:0x00000001bf3eb0 @seed=1234>

For detailed instructions, keep checking this repo, I'm working on getting a wiki up.

Benchmarks

PCGRandom.new_seed

Benchmark of Random.new_seed vs PCGRandom.new_seed
==================================================

Benchmark created around: 2016-03-30 14:54:16 +0000

Running for: 100000 iterations

Rehearsal ------------------------------------------------------
Random.new_seed      0.090000   1.240000   1.330000 (  1.323970)
PCGRandom.new_seed   0.100000   1.150000   1.250000 (  1.254944)
--------------------------------------------- total: 2.580000sec

                         user     system      total        real
Random.new_seed      0.110000   1.200000   1.310000 (  1.321571)
PCGRandom.new_seed   0.100000   1.130000   1.230000 (  1.222634)

PCGRandom.raw_seed(16)

Benchmark of Random.raw_seed(16) vs PCGRandom.raw_seed(16)
==================================================

Benchmark created around: 2016-03-30 14:41:26 +0000

Running for: 100000 iterations

Rehearsal ----------------------------------------------------------
Random.raw_seed(16)      0.080000   1.440000   1.520000 (  1.515513)
PCGRandom.raw_seed(16)   0.110000   1.320000   1.430000 (  1.444519)
------------------------------------------------- total: 2.950000sec

                             user     system      total        real
Random.raw_seed(16)      0.080000   1.470000   1.550000 (  1.563351)
PCGRandom.raw_seed(16)   0.090000   1.340000   1.430000 (  1.441253)

Roadmap

  • Achieve full parity with Kernel::Random
  • Get a wiki explaining how to go about using this gem
  • Showcase benchmarks in some other place

FAQs

Package last updated on 02 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc