From fc4b169f4e9a3b0e8c8ae807fdb4c7cf8d3e6507 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Tue, 27 Sep 2011 10:26:42 +0200 Subject: [PATCH] Add support for a constant random, for testing. --- deployment.cpp | 8 ++++++-- options.cpp | 9 ++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/deployment.cpp b/deployment.cpp index f34c3a9..bbb47e5 100644 --- a/deployment.cpp +++ b/deployment.cpp @@ -57,9 +57,13 @@ void deployment_generator::distribute_load() set_load(0, opt::auto_depl::load); return; } - srand48(opt::auto_depl::random_seed); std::vector loads(hosts.size()); - std::generate(loads.begin(), loads.end(), drand48); + if (opt::auto_depl::random_seed != 1) { + srand48(opt::auto_depl::random_seed); + std::generate(loads.begin(), loads.end(), drand48); + } else { + std::fill(loads.begin(), loads.end(), 1.0); + } double factor = opt::auto_depl::load / std::accumulate(loads.begin(), loads.end(), 0.0); std::transform(loads.begin(), loads.end(), loads.begin(), diff --git a/options.cpp b/options.cpp index a943339..c5f5c29 100644 --- a/options.cpp +++ b/options.cpp @@ -398,8 +398,8 @@ void opt::print() DESCR("- initial load (total)", "%g", auto_depl::load); DESCR("- random initial load distribution", "%s", h.on_off(auto_depl::random_distribution)); - DESCR("- random seed", "%s", - h.val_or_string(auto_depl::random_seed, "time based")); + DESCR("- random seed", "%s", // NOTE: cannot be 0 here anymore + h.val_or_string(auto_depl::random_seed, "constant random", 1UL)); } else { DESCR("deployment file", "\"%s\"", deployment_file.c_str()); } @@ -483,8 +483,11 @@ void opt::usage() << " [" << opt_helper::on_off(opt::auto_depl::random_distribution) << "]\n"; std::clog << o("-r value") - << "random seed, 0 for a seed based on current date" + << "random seed for initial load distribution, or 0, or 1" << " [" << opt::auto_depl::random_seed << "]\n"; + if (opt::help_requested > 1) + std::clog << o("") << "- use 0 for a seed based on current date\n" + << o("") << "- use 1 for a constant random\n"; std::clog << "\nLoad balancing algorithm:\n"; std::clog << o("-a name") << "load balancing algorithm" -- 2.39.5