MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Driver.hpp
1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil; -*-
2  * vim:expandtab:shiftwidth=4:tabstop=4:smarttab:
3  *
4  * Copyright (c) 2010, 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 Driver_hpp
21 #define Driver_hpp
22 
23 #include <iostream>
24 #include <sstream>
25 #include <fstream>
26 #include <string>
27 #include <vector>
28 
29 #include <sys/time.h>
30 
31 #include "Properties.hpp"
32 
33 using std::string;
34 using std::vector;
35 using std::ofstream;
36 using std::ostringstream;
37 
38 using utils::Properties;
39 
40 class Driver {
41 public:
42 
46  static void parseArguments(int argc, const char* argv[]);
47 
51  Driver() {}
52 
56  virtual ~Driver() {}
57 
61  void run();
62 
63 protected:
64 
65  // command-line arguments
66  static vector< string > propFileNames;
67  static string logFileName;
68 
69  static void exitUsage();
70 
71  // driver settings
72  Properties props;
73  int warmupRuns;
74 
75  // driver resources
76  ofstream log;
77  string descr;
78  bool logHeader;
79  ostringstream header;
80  ostringstream rtimes;
81  struct timeval t0, t1;
82  long rta;
83 
84  // driver intializers/finalizers
85  virtual void init();
86  virtual void close();
87  virtual void loadProperties();
88  virtual void initProperties();
89  virtual void printProperties();
90  virtual void openLogFile();
91  virtual void closeLogFile();
92 
93  // benchmark operations
94  virtual void runTests() = 0;
95  virtual void clearLogBuffers();
96  virtual void writeLogBuffers();
97  virtual void begin(const string& name);
98  virtual void finish(const string& name);
99 };
100 
101 #endif // Driver_hpp