[Assorted-commits] SF.net SVN: assorted:[1293] ydb/trunk/src/main.lzz.clamp
Brought to you by:
yangzhang
From: <yan...@us...> - 2009-03-13 19:27:05
|
Revision: 1293 http://assorted.svn.sourceforge.net/assorted/?rev=1293&view=rev Author: yangzhang Date: 2009-03-13 19:26:56 +0000 (Fri, 13 Mar 2009) Log Message: ----------- integrated tpcc into ydb Modified Paths: -------------- ydb/trunk/src/main.lzz.clamp Modified: ydb/trunk/src/main.lzz.clamp =================================================================== --- ydb/trunk/src/main.lzz.clamp 2009-03-13 19:26:26 UTC (rev 1292) +++ ydb/trunk/src/main.lzz.clamp 2009-03-13 19:26:56 UTC (rev 1293) @@ -1,4 +1,5 @@ #hdr +#define __STDC_FORMAT_MACROS #include <boost/archive/binary_iarchive.hpp> #include <boost/archive/binary_oarchive.hpp> #include <boost/bind.hpp> @@ -19,10 +20,11 @@ #include <csignal> // sigaction etc. #include <cstdio> #include <cstring> // strsignal -#include <iostream> #include <fstream> // ofstream #include <google/dense_hash_map> #include <gtest/gtest.h> +#include <inttypes.h> // PRId64 +#include <iostream> #include <malloc.h> #include <map> #include <netinet/in.h> // in_addr etc. @@ -33,6 +35,11 @@ #include <unistd.h> // pipe, write #include <vector> #include "ser.h" +#include "tpcc/clock.h" +#include "tpcc/randomgenerator.h" +#include "tpcc/tpccclient.h" +#include "tpcc/tpccgenerator.h" +#include "tpcc/tpcctables.h" #include "ydb.pb.h" #define function boost::function @@ -80,7 +87,7 @@ st_utime_t timeout; int yield_interval, accept_joiner_seqno, issuing_interval, min_ops, max_ops, stop_on_seqno, batch_size, handle_responses_display, - catch_up_display, issue_display, + catch_up_display, issue_display, nwarehouses, process_display; size_t accept_joiner_size, buf_size, read_buf_size; bool yield_during_build_up, yield_during_catch_up, dump, show_updates, @@ -1876,6 +1883,51 @@ } } +void +run_tpcc() +{ + TPCCTables* tables = new TPCCTables(); + SystemClock* clock = new SystemClock(); + + // Create a generator for filling the database. + RealRandomGenerator* random = new RealRandomGenerator(); + NURandC cLoad = NURandC::makeRandom(random); + random->setC(cLoad); + + // Generate the data + printf("Loading %d warehouses... ", nwarehouses); + fflush(stdout); + char now[Clock::DATETIME_SIZE+1]; + clock->getDateTimestamp(now); + TPCCGenerator generator(random, now, Item::NUM_ITEMS, + District::NUM_PER_WAREHOUSE, + Customer::NUM_PER_DISTRICT, + NewOrder::INITIAL_NUM_PER_DISTRICT); + int64_t begin = clock->getMicroseconds(); + generator.makeItemsTable(tables); + for (int i = 0; i < nwarehouses; ++i) { + generator.makeWarehouse(tables, i+1); + } + int64_t end = clock->getMicroseconds(); + printf("%"PRId64" ms\n", (end-begin)/1000); + + // Change the constants for run + random = new RealRandomGenerator(); + random->setC(NURandC::makeRandomForRun(random, cLoad)); + + // Client owns all the parameters + TPCCClient client(clock, random, tables, Item::NUM_ITEMS, static_cast<int>(nwarehouses), + District::NUM_PER_WAREHOUSE, Customer::NUM_PER_DISTRICT); + printf("Running... "); + fflush(stdout); + begin = clock->getMicroseconds(); + for (int i = 0; i < 200000; ++i) { + client.doOne(); + } + end = clock->getMicroseconds(); + printf("%"PRId64" ms\n", (end-begin)/1000); +} + /** * Initialization and command-line parsing. */ @@ -1971,6 +2023,9 @@ ("max-ops,O", po::value<int>(&max_ops)->default_value(5), "upper bound on randomly generated number of operations per txn (for leader)") + ("warehouses,w", + po::value<int>(&nwarehouses)->default_value(1), + "number of warehouses to model") ("accept-joiner-seqno,j", po::value<int>(&accept_joiner_seqno)->default_value(0), "accept recovering joiner (start recovery) after this seqno (for leader " This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |