MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CrundDriver.hpp
1 /* -*- mode: java; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=4:tabstop=4:smarttab:
3  *
4  * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; version 2 of the License.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18  */
19 
20 #ifndef CrundDriver_hpp
21 #define CrundDriver_hpp
22 
23 #include <string>
24 #include <vector>
25 #include <set>
26 
27 #include "hrt_utils.h"
28 
29 #include "Driver.hpp"
30 
31 using std::string;
32 using std::vector;
33 using std::set;
34 
35 class CrundDriver : public Driver {
36 protected:
37 
38  // benchmark settings
39  enum LockMode { READ_COMMITTED, SHARED, EXCLUSIVE };
40  static const char* toStr(LockMode mode);
41  enum XMode { SINGLE, BULK, BATCH }; // XXX not used yet
42  static const char* toStr(XMode mode); // XXX not used yet
43  bool renewConnection;
44  bool renewOperations;
45  LockMode lockMode;
46  bool logSumOfOps;
47  //bool allowExtendedPC; // not used
48  int nOpsStart;
49  int nOpsEnd;
50  int nOpsScale;
51  int maxVarbinaryBytes;
52  int maxVarcharChars;
53  int maxBlobBytes;
54  int maxTextChars;
55  set< string > exclude;
56 
57  // benchmark intializers/finalizers
58  virtual void init();
59  virtual void close();
60  virtual void initProperties();
61  virtual void printProperties();
62 
63  // measured units of work
64  struct Op {
65  const string name;
66 
67  virtual void run(int nOps) const = 0;
68 
69  Op(const string& name) : name(name) {}
70 
71  virtual ~Op() {}
72  };
73  typedef vector< const Op* > Operations;
74  Operations operations;
75 
76  // benchmark operations
77  virtual void initOperations() = 0;
78  virtual void closeOperations() = 0;
79  virtual void runTests();
80  virtual void runLoads(int nOps);
81  virtual void runOperations(int nOps);
82  virtual void runOp(const Op& op, int nOps);
83 
84  // datastore operations
85  virtual void initConnection() = 0;
86  virtual void closeConnection() = 0;
87  //virtual void clearPersistenceContext() = 0; // not used
88  virtual void clearData() = 0;
89 };
90 
91 #endif // CrundDriver_hpp