int main( ) { char filename[FILENAME_MAX]; int choice; CPUTimer ct; cout << "Filename >> "; cin >> filename; do { choice = getChoice(); ct.reset(); switch( choice ) { case 1: RunList( filename ); break; case 2: RunCursorList( filename ); break; case 3: RunStackAr( filename ); break; case 4: RunStackLi( filename ); break; case 5: RunQueueAr( filename ); break; case 6: RunSkipList( filename ); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl; } while( choice > 0 ); return 0; }
int main() { char a[1000]; cout << "Filename >> "; cin >> a; int choice; CPUTimer ct; do { cout << endl; choice = getChoice(); ct.reset(); switch (choice) { case 1: RunList(a); break; case 2: RunCursorList(a); break; case 3: RunStackAr(a); break; case 4: RunStackLi(a); break; case 5: RunQueueAr(a); break; case 6: RunSkipList(a); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl ; } while(choice > 0); }
int main(int argc, char* argv[]) { short **map, **map2; int width, cityCount, pathCounts[50]; Coordinates *cityPos; Router *router; CPUTimer ct; readFile(argv[1], &map, &map2, &width, &cityPos, &cityCount); Coordinates **paths = new Coordinates*[cityCount]; for(int i = 0; i < cityCount; i++) { paths[i] = new Coordinates[width * width]; // maximum number of edges possible pathCounts[i] = 0; } ct.reset(); router = new Router(map, width); for(int i = 0; i < width; i++) delete [] map[i]; delete [] map; router->findRoutes((const Coordinates*) cityPos, cityCount, paths, pathCounts); double time = ct.cur_CPUTime(); int trainTime = checkRoutes(map2, cityPos, cityCount, paths, pathCounts, width, argc); cout << "CPU time: " << time << " Train time: " << trainTime << endl; return 0; }
int main(int argc, char* argv[]) { Block *blocks; StreetSelecter *streetSelecter; int citySize, blockCount, numTrips, numWidened; Trip *trips, widenedBlocks[100]; char filename[80], command[80]; CPUTimer ct; if(argc != 2) { cout << "usage: RunCity.out CityFilename\n"; return 1; } ifstream inf(argv[1]); strcpy(filename, argv[1]); strtok(filename, "-"); strtok(NULL, "-"); numTrips = atoi(strtok(NULL, "-")); trips = new Trip[numTrips]; blocks = readFile(inf, citySize, blockCount, trips, numTrips); ct.reset(); streetSelecter = new StreetSelecter(blocks, blockCount, citySize, numTrips); delete [] blocks; streetSelecter->select(trips, numTrips, widenedBlocks, numWidened); // fills widenedBlocks cout << "CPU Time: " << ct.cur_CPUTime() << endl; writeSolution(argv[1], widenedBlocks, numWidened); // writes widenedBlocks to filename.ans sprintf(command,"./RunTrips.out %s", argv[1]); system(command); // runs trips of file using original and widened streets return 0; }
int main(){ string filename; cout << "Filename >> "; cin >> filename; CPUTimer ct; //cpu timer instance int choice; do { choice = getChoice(); ct.reset(); switch (choice) { case 1: RunList(filename); break; case 2: RunCursorList(filename); break; case 3: RunStackAr(filename); break; case 4: RunStackLi(filename); break; case 5: RunQueueAr(filename); break; case 6: RunSkipList(filename); break; } //switch cout << "CPU time: " << ct.cur_CPUTime() << endl; } while(choice > 0); }
int main(int argc, char **argv) { int operationCount, count; short scores[600]; const Operation *operations; operations = readFile(argv[1], &operationCount); CPUTimer ct; ct.reset(); GradeBook *gradeBook = new GradeBook(); if(argv[2][0] != '0') runTests(gradeBook, operations, operationCount); else { for(int i = 0; i < operationCount; i++) { switch(operations[i].type) { case LIST_STUDENT : gradeBook->listStudent(operations[i].CRN, operations[i].SID, &count, scores); break; case ADD_STUDENT : gradeBook->addStudent(operations[i].CRN, operations[i].SID); break; case REMOVE_STUDENT : gradeBook->removeStudent(operations[i].CRN, operations[i].SID); break; case UPDATE: gradeBook->update(operations[i].CRN, operations[i].title, operations[i].SID, operations[i].score); break; case LIST_ASSIGNMENT : gradeBook->listAssignment(operations[i].CRN, operations[i].title, &count, scores); break; case ENTER_SCORES : gradeBook->enterScores(operations[i].CRN, operations[i].title, operations[i].scores); break; case ADD_ASSIGNMENT : gradeBook->addAssignment(operations[i].CRN, operations[i].title, operations[i].maxScore); break; case ADD_COURSE : gradeBook->addCourse(operations[i].CRN); for (int j = 0; j < operations[i].count ; j++ ) gradeBook->addStudent(operations[i].CRN, operations[i].SIDs[j]); break; } // switch } // for i } // else no tests cout << "CPU Time: " << ct.cur_CPUTime() << endl; return 0; } // main()
int main(int argc, char* argv[]) { ifstream inf(argv[1]); int generations, pairs, queryCount, familyCount; char dummy; inf >> generations >> dummy >> pairs >> dummy >> queryCount; inf.ignore(10, '\n'); Family *families = new Family[200000]; Query *queries = new Query[queryCount]; Person *answers = new Person[queryCount]; Person *answerKeys = new Person[queryCount]; readQueries(inf, queries, answerKeys, queryCount); familyCount = readFamilies(inf, families); CPUTimer ct; ct.reset(); FamilyTree *familyTree = new FamilyTree(families, familyCount); delete [] families; familyTree->runQueries(queries, answers, queryCount); cout << "CPU Time: " << ct.cur_CPUTime() << endl; for(int i = 0; i < queryCount; i++) if(answerKeys[i].year == -1) { if(answers[i].year != -1) { cout << "You found an ancestor when there was none on query #" << i << endl; cout << "Descendent 1: " << queries[i].person1.year << ' ' << queries[i].person1.lastName << ',' << queries[i].person1.firstName << endl; cout << "Descendent 2: " << queries[i].person2.year << ' ' << queries[i].person2.lastName << ',' << queries[i].person2.firstName << endl; cout << "Your answer:" << answers[i].year << ' ' << answers[i].lastName << ',' << answers[i].firstName << endl; } } else // An ancestor should be found if(answers[i].year != answerKeys[i].year || strcmp(answers[i].lastName, answerKeys[i].lastName) != 0 || strcmp(answers[i].firstName, answerKeys[i].firstName) != 0 || answers[i].gender != answerKeys[i].gender) { cout << "Disagreement on query #" << i << endl; cout << "Descendent 1: " << queries[i].person1.year << ' ' << queries[i].person1.lastName << ',' << queries[i].person1.firstName << endl; cout << "Descendent 2: " << queries[i].person2.year << ' ' << queries[i].person2.lastName << ',' << queries[i].person2.firstName << endl; cout << "Proper answer: " << answerKeys[i].year << ' ' << answerKeys[i].lastName << ',' << answerKeys[i].firstName << endl; cout << "Your answer:" << answers[i].year << ' ' << answers[i].lastName << ',' << answers[i].firstName << endl; } return 0; } // main()
int main(int argc, char *argv[]) { DiskDrive diskDrive; diskDrive.readFile(argv[1]); CPUTimer ct; currentRAM = maxRAM = 0; ct.reset(); new Defragmenter(&diskDrive); cout << "CPU Time: " << ct.cur_CPUTime() << " Disk accesses: " << diskDrive.getDiskAccesses() << " RAM: " << maxRAM << endl; diskDrive.check(); return 0; } // main
int main (int argc, char** argv) { CPUTimer ct; int choice; char filename[79]; cout << "Filename: "; cin >> filename; do { choice = getChoice(); ct.reset(); switch (choice) //Switch statement based on user's choice { case 1: RunList(filename); break; case 2: RunCursorList(filename); break; case 3: RunStackAr(filename); break; case 4: RunStackLi(filename); break; case 5: RunQueueAr(filename); break; case 6: RunSkipList(filename); break; } // end switch cout << "CPU time: " << ct.cur_CPUTime() << endl; } while (choice > 0); //end doWhile return 0; }//main
int main(int argc, char** argv) { int numOperations, numInserts; const char *result; Operation *operations; CPUTimer ct; initializeNew(); // determines if malloc uses 1 or 2 ints for size. SongInfo *songInfos = new SongInfo[1000000]; readTrackFile(songInfos); SongInfo2 *songInfos2 = readSalesFile(argv[1], &numInserts, &numOperations, songInfos, &operations); ct.reset(); Sales *sales = new Sales(songInfos2, numInserts); delete [] songInfos2; maxRAM = currentRAM; // eliminated the songInfos2 size for(int i = 0; i < numOperations; i++) { // if(i == 465) // cout << i << endl; if(operations[i].operation == 'A') { result = sales->artistList( songInfos[operations[i].indices[0]].artist, operations[i].indices[1]); checkResult(result, songInfos[operations[i].indices[2]].trackID, i); } // if artistList else // purchase { result = sales->purchase( songInfos[operations[i].indices[0]].song, songInfos[operations[i].indices[0]].artist, songInfos[operations[i].indices[1]].song, songInfos[operations[i].indices[1]].artist, operations[i].indices[2]); checkResult(result, songInfos[operations[i].indices[3]].trackID, i); } // else purchae } // for each operation cout << "CPU Time: " << ct.cur_CPUTime() << " maxRAM: " << maxRAM << endl; return 0; } // main())
int main(){ ifstream inputFile; //char strin[20]; char fileName[20]; char iord; int number; int choice; CPUTimer ct; cout << "Filename >> "; cin >> fileName; inputFile.open(fileName); do { choice = getChoice(); ct.reset(); //string dummy; //getline(thestream, dummy); //for(int i = 0; i < 10; i++){ //thestream >> iord >> number; //cout << iord; //cout << number << endl; //} //PassStream(inputFile); //RunList(); switch(choice) { case 1: RunList(inputFile); break; case 2: RunCursorList(inputFile); break; case 3: RunStackAr(inputFile); break; case 4: RunStackLi(inputFile); break; case 5: RunQueueAr(inputFile); break; case 6: RunSkipList(inputFile); break; } cout << "CPU time: " << ct.cur_CPUTime() << endl; }while(choice > 0); return 0; }
int main(){ unsigned int n_lines, max_val, i, ret, a = 0, b = 0, c = 0; bst_ret b_ret; char op; bst * h = NULL; scanf(" %u %u", &n_lines, &max_val); /* Create the binary tree */ b_ret = bst_create(&h, n_lines); if(b_ret == bst_NoMem){ printf("ERROR: No memory to create bst tree!\n"); printf("\t\tSize: %u\n", n_lines); exit(1); } /* Intiatializing time variables */ insTime.reset(); searchTime.reset(); remTime.reset(); /* Read the input file */ for(i = 0; i < n_lines; i++){ scanf(" %c %*d %[^\n]", &op, set); switch( op ){ /* Insertion */ case 'i': ret = insert(h, set); #ifdef _LOG if( ret == OP_OK ) printf("i OK %s\n", set); else if( ret == PREV_INSERTED ) printf("i PREV %s\n", set); else if( ret == BST_FULL) { printf("ERROR: bst if full!\n\tcould not insert %s\n", set); exit( 1 ); } #endif a++; break; /* Search */ case 'b': ret = search(h, set); #ifdef _LOG if( ret == OP_OK ) printf("b FND %s\n", set); else printf("b ~FND %s\n", set); #endif b++; break; /* Removal */ case 'r': ret = _delete(h, set); #ifdef _LOG if( ret == OP_OK ) printf("r OK %s\n", set); else printf("r ~FND %s\n", set); #endif c++; break; /* Wrong code */ default: printf("ERROR: Wrong input at line %u!\n", i+1); exit(1); } } if(a == 0) a++; if(b == 0) b++; if(c == 0) c++; printf("\n\nSTATISTICS\n==========\n\n"); /* Insertion */ printf(" Insertion Total Time: %lfs\n\tInsertion Average Time: %.12lfms\n", insTime.getCPUTotalSecs(), (insTime.getCPUTotalSecs() / a) * 1000 ); /* Search */ printf(" Search Total Time: %lfs\n\tSearch Average Time: %.12lfms\n", searchTime.getCPUTotalSecs(), (searchTime.getCPUTotalSecs() / b) * 1000 ); /* Removal */ printf(" Remove Total Time: %lfs\n\tRemove Average Time: %.12lfms\n", remTime.getCPUTotalSecs(), (remTime.getCPUTotalSecs() / c) * 1000 ); /* Total running time */ printf("Total Running time: %lfs\n", ( remTime.getCPUTotalSecs() + searchTime.getCPUTotalSecs() + insTime.getCPUTotalSecs() ) ); bst_destroy(h); return 0; }
/** * Reads in the input file, performs the KP-frac linear time strategy on the * input and displays the optimal solution. */ int main (int argc, char * argv[]) { if (argc <= 1) { std::cout << "Please indicate the name of the input file." << std::endl; return -1; } CPUTimer timer; std::cout << "Instance, Avg Running Time (s), Number of Iterations, Value" << std::endl; for (int fileIdx = 1; fileIdx < argc; fileIdx++) { parser(argv[fileIdx]); Object * temp = new Object[num_elem]; for (int i = 0; i < num_elem; i++) temp[i] = objects[i]; timer.reset(); int it = 0; while (timer.getCPUTotalSecs() < 5.0) { inserted.clear(); timer.start(); kpfrac_linear(objects, num_elem, W); timer.stop(); it++; for(int j = 0; j < num_elem; j++) objects[j] = temp[j]; } double media = timer.getCPUTotalSecs() / it; std::cout << argv[fileIdx] << "," << media << "," << it; // Loop over the array of objects and display which were inserted and with // what frequency. double totalValue = 0; #ifdef DEBUG std::cout << "Elem | Value | Weight | Density | Frequency" << std::endl; #endif for (int i = 0, len = inserted.size(); i < len; i++) { Object obj = inserted[i]; #ifdef DEBUG std::cout << "Elem | Value | Weight | Density | Frequency" << std::endl; std::cout << obj.elem << " " << obj.value << " " << obj.weight << " " << obj.density << " " << obj.frequency << std::endl; #endif totalValue += obj.frequency * obj.value; } std::cout << std::setprecision(15) << "," << totalValue << std::endl; delete [] objects; inserted.clear(); } return 0; }
int main() { int choice; char filename[100]; int i = 0, k = 0, m = 0; cout << "Filename >> "; cin.getline(filename,100); CPUTimer ct; do { choice = getChoice(); ct.reset(); switch(choice) { case 1: // RunList(filename); { RunList(filename); break; } case 2: //RunCursorList(filename); { RunCursorList(filename); break; } case 3: //RunStackAr(filename); { RunStackAr(filename); break; } case 4: //RunStackLi(filename); { RunStackLi(filename); break; } case 5: //RunQueueAr(filename); { RunQueueAr(filename); break; } case 6: //RunSkipList(filename); { RunSkipList(filename); break; } } cout << "CPU time: " << ct.cur_CPUTime() << endl; }while(choice > 0); return (0); }