25 #include "helpers.hpp"
26 #include "string_helpers.hpp"
28 #include "CrundDriver.hpp"
34 using std::ostringstream;
40 using utils::toString;
51 CrundDriver::close() {
57 CrundDriver::initProperties() {
58 Driver::initProperties();
60 cout <<
"setting crund properties ..." << flush;
64 renewConnection = toBool(props[L
"renewConnection"],
false);
65 renewOperations = toBool(props[L
"renewOperations"],
false);
67 string lm = toString(props[L
"lockMode"]);
69 lockMode = READ_COMMITTED;
70 }
else if (lm.compare(
"READ_COMMITTED") == 0) {
71 lockMode = READ_COMMITTED;
72 }
else if (lm.compare(
"SHARED") == 0) {
74 }
else if (lm.compare(
"EXCLUSIVE") == 0) {
77 msg <<
"[ignored] lockMode: '" << lm <<
"'" << endl;
78 lockMode = READ_COMMITTED;
81 logSumOfOps = toBool(props[L
"logSumOfOps"],
true);
84 nOpsStart = toInt(props[L
"nOpsStart"], 256, 0);
86 msg <<
"[ignored] nOpsStart: '"
87 << toString(props[L
"nOpsStart"]) <<
"'" << endl;
90 nOpsEnd = toInt(props[L
"nOpsEnd"], nOpsStart, 0);
91 if (nOpsEnd < nOpsStart) {
92 msg <<
"[ignored] nOpsEnd: '"
93 << toString(props[L
"nOpsEnd"]) <<
"'" << endl;
96 nOpsScale = toInt(props[L
"nOpsScale"], 2, 0);
98 msg <<
"[ignored] nOpsScale: '"
99 << toString(props[L
"nOpsScale"]) <<
"'" << endl;
103 maxVarbinaryBytes = toInt(props[L
"maxVarbinaryBytes"], 100, 0);
104 if (maxVarbinaryBytes < 1) {
105 msg <<
"[ignored] maxVarbinaryBytes: '"
106 << toString(props[L
"maxVarbinaryBytes"]) <<
"'" << endl;
107 maxVarbinaryBytes = 100;
109 maxVarcharChars = toInt(props[L
"maxVarcharChars"], 100, 0);
110 if (maxVarcharChars < 1) {
111 msg <<
"[ignored] maxVarcharChars: '"
112 << toString(props[L
"maxVarcharChars"]) <<
"'" << endl;
113 maxVarcharChars = 100;
116 maxBlobBytes = toInt(props[L
"maxBlobBytes"], 1000, 0);
117 if (maxBlobBytes < 1) {
118 msg <<
"[ignored] maxBlobBytes: '"
119 << toString(props[L
"maxBlobBytes"]) <<
"'" << endl;
122 maxTextChars = toInt(props[L
"maxTextChars"], 1000, 0);
123 if (maxTextChars < 1) {
124 msg <<
"[ignored] maxTextChars: '"
125 << toString(props[L
"maxTextChars"]) <<
"'" << endl;
130 const wstring& estr = props[L
"exclude"];
132 const size_t len = estr.length();
133 size_t beg = 0, next;
135 && ((next = estr.find_first_of(L
",", beg)) != wstring::npos)) {
138 const wstring& s = estr.substr(beg, next - beg);
139 exclude.insert(toString(s));
145 const wstring& s = estr.substr(beg, len - beg);
146 exclude.insert(toString(s));
151 <<
"nOps=" << nOpsStart <<
".." << nOpsEnd <<
"]" << endl;
153 cout << endl << msg.str() << endl;
158 CrundDriver::printProperties() {
159 Driver::printProperties();
161 const ios_base::fmtflags f = cout.flags();
164 cout.flags(ios_base::boolalpha);
166 cout << endl <<
"crund settings ..." << endl;
167 cout <<
"renewConnection: " << renewConnection << endl;
168 cout <<
"renewOperations: " << renewOperations << endl;
169 cout <<
"lockMode: " << toStr(lockMode) << endl;
170 cout <<
"logSumOfOps: " << logSumOfOps << endl;
172 cout <<
"nOpsStart: " << nOpsStart << endl;
173 cout <<
"nOpsEnd: " << nOpsEnd << endl;
174 cout <<
"nOpsScale: " << nOpsScale << endl;
175 cout <<
"maxVarbinaryBytes: " << maxVarbinaryBytes << endl;
176 cout <<
"maxVarcharChars: " << maxVarcharChars << endl;
177 cout <<
"maxBlobBytes: " << maxBlobBytes << endl;
178 cout <<
"maxTextChars: " << maxTextChars << endl;
179 cout <<
"exclude: " << toString(exclude) << endl;
187 CrundDriver::runTests() {
192 assert(nOpsStart <= nOpsEnd && nOpsScale > 1);
193 for (
int i = nOpsStart;
i <= nOpsEnd;
i *= nOpsScale) {
198 <<
"------------------------------------------------------------" << endl
206 CrundDriver::runLoads(
int nOps) {
208 <<
"------------------------------------------------------------" << endl;
210 cout <<
"running operations ..."
211 <<
" [nOps=" << nOps <<
"]" << endl;
224 if (renewConnection) {
229 }
else if (renewOperations) {
241 cout <<
"tx real time " << rta
245 cout <<
"tx cpu time " << cta
259 rtimes <<
"\t" << rta;
265 ctimes <<
"\t" << cta;
272 CrundDriver::runOperations(
int nOps) {
273 for (Operations::const_iterator
i = operations.begin();
274 i != operations.end(); ++
i) {
286 CrundDriver::runOp(
const Op& op,
int nOps) {
287 const string&
name = op.name;
288 if (exclude.find(name) == exclude.end()) {
296 CrundDriver::toStr(XMode
mode) {
306 return "<invalid value>";
311 CrundDriver::toStr(LockMode mode) {
314 return "read_committed";
321 return "<invalid value>";