From: Date: September 5 2007 9:06pm Subject: bk commit into 5.2 tree (cmiller:1.2591) BUG#30793 List-Archive: http://lists.mysql.com/commits/33759 X-Bug: 30793 Message-Id: <20070905190643.1155A83051@zippy> Below is the list of changes that have just been committed into a local 5.2 repository of cmiller. When cmiller does a push these changes will be propagated to the main repository and, within 24 hours after the push, to the public repository. For information on how to access the public repository see http://dev.mysql.com/doc/mysql/en/installing-source-tree.html ChangeSet@stripped, 2007-09-05 15:06:37-04:00, cmiller@stripped +1 -0 Bug#30793: set random seed for mysqlslap Contributed patch from "mushuiliu". No CLA. Add a new parameter "set-random-seed", which takes an uint as an argument. If the parameter isn't used or is used for value "0", then the random_seed is set from time() as usual. Print the seed value in the output, so a run can be replayed. client/mysqlslap.c@stripped, 2007-09-05 15:06:35-04:00, cmiller@stripped +11 -1 Add a new parameter "set-random-seed", which takes an uint as an argument. If the parameter isn't used or is used for value "0", then the random_seed is set from time() as usual. Print the seed value in the output, so a run can be replayed. diff -Nrup a/client/mysqlslap.c b/client/mysqlslap.c --- a/client/mysqlslap.c 2007-08-13 09:11:09 -04:00 +++ b/client/mysqlslap.c 2007-09-05 15:06:35 -04:00 @@ -140,6 +140,7 @@ static my_bool opt_compress= FALSE, tty_ auto_generate_sql= FALSE; const char *auto_generate_sql_type= "mixed"; +static unsigned int random_seed= 0; static unsigned long connect_flags= CLIENT_MULTI_RESULTS; static int verbose, delimiter_length; @@ -308,7 +309,11 @@ int main(int argc, char **argv) /* Seed the random number generator if we will be using it. */ if (auto_generate_sql) - srandom((uint)time(NULL)); + { + if (random_seed == 0) + random_seed= (uint) time(NULL); + srandom(random_seed); + } /* globals? Yes, so we only have to run strlen once */ delimiter_length= strlen(delimiter); @@ -645,6 +650,10 @@ static struct my_option my_long_options[ {"query", 'q', "Query to run or file containing query to run.", (uchar**) &user_supplied_query, (uchar**) &user_supplied_query, 0, GET_STR, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, + {"set-random-seed", 'r', + "Seed random number generator. Zero (default) uses time.", + (uchar**)&random_seed, (uchar**)&random_seed, + 0, GET_UINT, REQUIRED_ARG, 0, 0, 0, 0, 0, 0}, #ifdef HAVE_SMEM {"shared-memory-base-name", OPT_SHARED_MEMORY_BASE_NAME, "Base name of shared memory.", (uchar**) &shared_memory_base_name, @@ -2050,6 +2059,7 @@ print_conclusions(conclusions *con) printf("Benchmark\n"); if (con->engine) printf("\tRunning for engine %s\n", con->engine); + printf("\tRand Seed:%lu\n", random_seed); printf("\tAverage number of seconds to run all queries: %ld.%03ld seconds\n", con->avg_timing / 1000, con->avg_timing % 1000); printf("\tMinimum number of seconds to run all queries: %ld.%03ld seconds\n",