20 #include "TwsDriver.hpp"
28 #include "helpers.hpp"
29 #include "string_helpers.hpp"
30 #include "Properties.hpp"
37 using std::ostringstream;
42 using utils::toString;
48 #define ABORT_VERIFICATION_ERROR() \
49 do { cout << "!!! error in " << __FILE__ << ", line: " << __LINE__ \
50 << ", failed data verification." << endl; \
69 TwsDriver::initProperties() {
70 Driver::initProperties();
72 cout <<
"setting tws properties ..." << flush;
76 renewConnection = toBool(props[L
"renewConnection"],
false);
77 doInsert = toBool(props[L
"doInsert"],
true);
78 doLookup = toBool(props[L
"doLookup"],
true);
79 doUpdate = toBool(props[L
"doUpdate"],
true);
80 doDelete = toBool(props[L
"doDelete"],
true);
81 doSingle = toBool(props[L
"doSingle"],
true);
82 doBulk = toBool(props[L
"doBulk"],
true);
83 doBatch = toBool(props[L
"doBatch"],
true);
84 doVerify = toBool(props[L
"doVerify"],
true);
86 string lm = toString(props[L
"lockMode"]);
88 lockMode = READ_COMMITTED;
89 }
else if (lm.compare(
"READ_COMMITTED") == 0) {
90 lockMode = READ_COMMITTED;
91 }
else if (lm.compare(
"SHARED") == 0) {
93 }
else if (lm.compare(
"EXCLUSIVE") == 0) {
96 msg <<
"[ignored] lockMode: '" << lm <<
"'" << endl;
97 lockMode = READ_COMMITTED;
100 nRows = toInt(props[L
"nRows"], 256, 0);
102 msg <<
"[ignored] nRows: '"
103 << toString(props[L
"nRows"]) <<
"'" << endl;
107 nRuns = toInt(props[L
"nRuns"], 1, -1);
109 msg <<
"[ignored] nRuns: '"
110 << toString(props[L
"nRuns"]) <<
"'" << endl;
115 if (msg.str().empty()) {
116 cout <<
" [ok]" << endl;
118 cout << endl << msg.str() << endl;
123 TwsDriver::printProperties() {
124 Driver::printProperties();
126 const ios_base::fmtflags f = cout.flags();
129 cout.flags(ios_base::boolalpha);
131 cout << endl <<
"tws settings..." << endl;
132 cout <<
"renewConnection: " << renewConnection << endl;
133 cout <<
"doInsert: " << doInsert << endl;
134 cout <<
"doLookup: " << doLookup << endl;
135 cout <<
"doUpdate: " << doUpdate << endl;
136 cout <<
"doDelete: " << doDelete << endl;
137 cout <<
"doSingle: " << doSingle << endl;
138 cout <<
"doBulk: " << doBulk << endl;
139 cout <<
"doBatch: " << doBatch << endl;
140 cout <<
"doVerify: " << doVerify << endl;
141 cout <<
"lockMode: " << toStr(lockMode) << endl;
142 cout <<
"nRows: " << nRows << endl;
143 cout <<
"nRuns: " << nRuns << endl;
151 TwsDriver::runTests() {
162 TwsDriver::runLoads() {
168 TwsDriver::runSeries() {
173 <<
"------------------------------------------------------------" << endl;
174 cout <<
"running " << nRuns <<
" iterations on load: " << descr;
176 for (
int i = 0;
i < nRuns;
i++) {
178 <<
"------------------------------------------------------------" << endl;
187 TwsDriver::runOperations() {
189 rtimes <<
"nRows=" << nRows;
193 if (renewConnection) {
203 cout <<
"tx real time " << rta
211 rtimes <<
"\t" << rta << endl;
215 TwsDriver::verify(
int exp,
int act) {
219 ABORT_VERIFICATION_ERROR();
225 TwsDriver::verify(
long exp,
long act) {
229 ABORT_VERIFICATION_ERROR();
235 TwsDriver::verify(
long long exp,
long long act) {
239 ABORT_VERIFICATION_ERROR();
245 TwsDriver::verify(
const char* exp,
const char* act) {
248 if (strcmp(exp, act) != 0) {
249 ABORT_VERIFICATION_ERROR();
255 TwsDriver::toStr(XMode
mode) {
265 return "<invalid value>";
270 TwsDriver::toStr(LockMode mode) {
273 return "read_committed";
280 return "<invalid value>";