Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Commit

Permalink
use fixed seeds for rand_{small,large} benchmark
Browse files Browse the repository at this point in the history
- seeds were produced by running unpredictableSeed
  • Loading branch information
MartinNowak committed Jan 23, 2015
1 parent 9ec0c65 commit d495417
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 7 deletions.
17 changes: 13 additions & 4 deletions benchmark/gcbench/rand_large.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,23 @@ import std.random, core.memory, std.stdio;

enum nIter = 1000;

void main() {
void main()
{
version (RANDOMIZE)
auto rnd = Random(unpredictableSeed);
else
auto rnd = Random(1202387523);

auto ptrs = new void*[1024];

// Allocate 1024 large blocks with size uniformly distributed between 1
// and 128 kilobytes.
foreach(i; 0..nIter) {
foreach(ref ptr; ptrs) {
ptr = GC.malloc(uniform(1024, 128 * 1024 + 1), GC.BlkAttr.NO_SCAN);
foreach(i; 0..nIter)
{
foreach(ref ptr; ptrs)
{
immutable sz = uniform(1024, 128 * 1024 + 1, rnd);
ptr = GC.malloc(sz, GC.BlkAttr.NO_SCAN);
}
}
}
14 changes: 11 additions & 3 deletions benchmark/gcbench/rand_small.d
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,21 @@ void main(string[] args)
if(args.length > 1)
nIter = to!size_t(args[1]);

version (RANDOMIZE)
auto rnd = Random(unpredictableSeed);
else
auto rnd = Random(2929088778);

auto ptrs = new void*[4096];

// Allocate large blocks with size uniformly distributed between 8
// and 2048 bytes.
foreach(i; 0..nIter) {
foreach(ref ptr; ptrs) {
ptr = GC.malloc(uniform(8, 2048), GC.BlkAttr.NO_SCAN);
foreach(i; 0..nIter)
{
foreach(ref ptr; ptrs)
{
immutable sz = uniform(8, 2048, rnd);
ptr = GC.malloc(sz, GC.BlkAttr.NO_SCAN);
}
}
}

0 comments on commit d495417

Please sign in to comment.