Skip to content
  • dalecurtis@chromium.org's avatar
    Improve base::RandBytes() performance by 1.75x-2.10x on POSIX. · c910c5a6
    dalecurtis@chromium.org authored
    No real changes, just avoids doling out Uint64 sized chunks by
    using the underlying method to hand out correctly sized blocks.
    
    Windows is the only platform which doesn't have a byte stream
    based generator, so I've moved the generic RandBytes() method
    there and added native methods for other platforms which reuse
    each platforms internal generator.
    
    Performance measured by the new benchmark test over 5 runs,
    each representing 10 generations of 1mb of random data:
    
    Linux x64:
    Original: 1199625.4
    Modified: 686480.2
    Improvement: 1.75x
    
    On OSX (10.9.1):
    Original: 1532669.8
    Modified: 734808.0
    Improvement: 2.10x
    
    BUG=none
    TEST=new benchmark unittest.
    
    Review URL: https://codereview.chromium.org/140773006
    
    git-svn-id: svn://svn.chromium.org/chrome/trunk/src@246486 0039d316-1c4b-4281-b951-d872f2087c98
    c910c5a6