Uploaded image for project: 'Commons RNG'
  1. Commons RNG
  2. RNG-76

Add a primitive constructor to SplitMix64

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Trivial
    • Resolution: Implemented
    • 1.3
    • 1.3
    • core
    • None

    Description

      The constructor for SplitMix64 uses a Long for the seed. If constructed using a primitive long then auto-boxing will occur.

      I added a long version of the constructor to SplitMix64:

      SplitMix64(Long seed);
      SplitMix64(long seed);
      

      I modified the ConstructionPerformance benchmark to generate 5000 random seeds as Long or long then tested:

      // Pre-generated Long
      new SplitMix64(Long seed);
      
      // Pre-generated long that is boxed to Long
      new SplitMix64(Long.valueOf(long seed));
      
      // Pre-generated long
      new SplitMix64(long seed);
      

      Results:

      Method Score Error Median
      newSplitMix64Long 34.70 0.85 34.57
      newSplitMix64LongValueOf 55.84 5.38 55.91
      newSplitMix64long 32.66 1.49 32.46

      Given that the SplitMix64 is the preferred RNG for seeding from a single long value it makes sense to add the constructor version that accepts a long.

      Attachments

        Issue Links

          Activity

            People

              aherbert Alex Herbert
              aherbert Alex Herbert
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 40m
                  40m