/* cartSimNoInsert - simulates N users accessing cart at regular intervals * where cart data is read and then written back unchanged */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "cheapcgi.h" #include "jksql.h" #include "portable.h" int userCount = 10; int randSeed = 0; boolean readOnly = FALSE; void usage() /* Explain usage and exit. */ { errAbort( "cartSimNoInsert - simulates N users accessing cart at regular intervals\n" " where cart data is read and then written back unchanged\n" "usage:\n" " cartSimNoInsert host user password database milliDelay iterations\n" "where:\n" " host is the MySQL host name - example mysqlbeta\n" " user is the MySQL user name - example hgcentuser\n" " password is the MySQL password\n" " database is the MySQL database - example hgcentralbeta\n" " milliDelay is the number of milliseconds to delay between requests\n" " iterations is the number of cart read/write accesses to do\n" "options:\n" " -userCount=N number of users simulating. Default %d\n" " -randSeed=N random number generator seed. Defaults to pid\n" " -readOnly - don't write to cart\n" , userCount ); } int *getSomeInts(struct sqlConnection *conn, char *table, char *field, int limit) /* Return an array of ints from field in table. */ { int *result, i; char query[512]; safef(query, sizeof(query), "select %s from %s limit %d", field, table, limit); struct sqlResult *sr = sqlGetResult(conn, query); AllocArray(result, limit); for (i=0; i= iterations) return; } } } int main(int argc, char *argv[]) /* Process command line. */ { cgiSpoof(&argc, argv); userCount = cgiOptionalInt("userCount", userCount); randSeed = cgiOptionalInt("randSeed", (int)getpid()); verboseSetLevel(cgiOptionalInt("verbose", 1)); readOnly = cgiVarExists("readOnly"); srand(randSeed); if (argc != 7) usage(); cartSimNoInsert(argv[1], argv[2], argv[3], argv[4], argv[5], argv[6]); return 0; }