本文整理汇总了C++中Disk::resetDiskTimer方法的典型用法代码示例。如果您正苦于以下问题:C++ Disk::resetDiskTimer方法的具体用法?C++ Disk::resetDiskTimer怎么用?C++ Disk::resetDiskTimer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Disk
的用法示例。
在下文中一共展示了Disk::resetDiskTimer方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main() {
//=======================Initialization=========================
cout << "=======================Initialization=========================" << endl;
// Initialize the memory, disk and the schema manager
MainMemory mem;
Disk disk;
cout << "The memory contains " << mem.getMemorySize() << " blocks" << endl;
cout << mem << endl << endl;
SchemaManager schema_manager(&mem,&disk);
Schema *schema;
disk.resetDiskIOs();
disk.resetDiskTimer();
// Another way to time
clock_t start_time;
start_time=clock();
// TODO Set up a block here??
//=========================Initialization ends ==========================
string line;
vector<string> strings;
ifstream myfile ("TinySQL_linux.txt");
if(myfile.is_open()) {
while(getline (myfile,line)) {
//cout << line << '\n';
istringstream f(line);
string s;
while(getline(f, s, ' ')) {
//cout << s << endl;
strings.push_back(s);
}
if(strings[0].compare("CREATE") == 0) {
// Creating a schema for the create statement.
schema = processCreate(strings);
//printSchema(*schema);
// Creating the relation with the schema above using schema manager.
string relation_name=strings[2];
cout << "Creating table " << relation_name << endl;
Relation* relation_ptr=schema_manager.createRelation(relation_name, *schema);
//printRelation(relation_ptr);
}
// TODO Change the command to lower-case and compare
else if(strings[0].compare("INSERT") == 0) {
cout << "It is an INSERT statement " << endl;
processInsert(line, strings, schema_manager);
}
else if(strings[0].compare("SELECT") == 0) {
cout << "It is a SELECT statement " << endl;
processSelect(line, strings, schema_manager, &mem);
}
strings.clear();
}
myfile.close();
}
else cout << "Unable to open file";
return 0;
}
示例2: main
int main(int argc, char ** argv){
// Initialize the memory, disk and the schema manager
MainMemory mem;
Disk disk;
//cout << "The memory contains " << mem.getMemorySize() << " blocks" << endl;
SchemaManager schema_manager(&mem,&disk);
disk.resetDiskIOs();
disk.resetDiskTimer();
resetFreeBlocks();
clock_t start_time;
start_time=clock();
//=======================Read Input=========================
ifstream input;
bool interactive_mode = false;
assert(argv && argc >= 1);
cout<<endl;
cout<<" ";
cout<<"============================================="<<endl<<endl;
cout<<" ";
cout<<"Welcome to TinySQL Database Management System"<<endl<<endl;
cout<<" ";
cout<<"Develped by Jimmy Jin & Tony Wang, 12/6/2016"<<endl<<endl;
cout<<" ";
cout<<"============================================="<<endl<<endl;
if (argc == 1){
cout<<endl<<"Entering Interactive Mode: Type query and ENTER to execute; Type EXIT to exit the program."<<endl<<endl;
interactive_mode = true;
}
else if (argc == 2){
string filename = argv[1];
input.open(filename.c_str());
if (!input.is_open()){
cout<<"Cannot Open file: "<<filename<<endl;
return 0;
}
}
else{
cout<<"To use TinySQL to read input file, type: ";
cout<<"./Tiny <filename>"<<endl;
cout<<"To use TinySQL in Interactive Mode, type: ";
cout<<"./Tiny"<<endl;
return 0;
}
unsigned long int ios = 0;
double time = 0;
string line;
vector<string> words;
// for each command line
while(1){
if (interactive_mode){
cout<<">>";
char console_input[1000];
cin.getline(console_input, sizeof(console_input));
line = string(console_input);
if (line == "EXIT") break;
cout<<endl;
}
else{
if (!getline(input, line)) break;
cout<<line<<endl;
}
if(line[0] == '#') continue;
if(line.size() == 0) continue;
// extract each word into vector words
words = splitBy(line," ");
// prepare memory
resetFreeBlocks();
if (words[0] == "CREATE"){
Create(words, schema_manager, mem);
}
else if (words[0] == "DROP"){
string relation_name = words[2];
schema_manager.deleteRelation(relation_name);
}
else if (words[0] == "INSERT"){
Insert(words, line, schema_manager, mem);
// cout<< *(schema_manager.getRelation(relation_name))<<endl;
}
else if (words[0] == "DELETE"){
Delete(words, schema_manager, mem);
}
else if (words[0] == "SELECT"){
Select(words, schema_manager, mem);
}
else{
cout<<"Not a valid Tiny-SQL command!"<<endl<<endl;
continue;
//abort();
}
words.clear();
cout << "Elapse time = " << disk.getDiskTimer() - time<< " ms" << endl;
cout << "Disk I/Os = " << disk.getDiskIOs() - ios<< endl<<endl;
time = disk.getDiskTimer();
//.........这里部分代码省略.........