当前位置: 首页>>代码示例>>C++>>正文


C++ CPUTimer类代码示例

本文整理汇总了C++中CPUTimer的典型用法代码示例。如果您正苦于以下问题:C++ CPUTimer类的具体用法?C++ CPUTimer怎么用?C++ CPUTimer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了CPUTimer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

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;
}
开发者ID:delhuy12,项目名称:ecs60,代码行数:32,代码来源:RunCity.cpp

示例2: main

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);	

} 
开发者ID:chardima,项目名称:ECS60,代码行数:29,代码来源:timetest.cpp

示例3: CHECK

void MyDataLayer<Dtype>::load_batch(Batch<Dtype>* batch){
    CPUTimer batch_timer;
    batch_timer.Start();
    double read_time = 0;
    double trans_time = 0;
    CPUTimer timer;
    CHECK(batch->data_.count());
    CHECK(this->transformed_data_.count());

    MyDataParameter my_data_param = this-> layer_param_.my_data_param();
    // Get batch size
    const int batch_size = my_data_param.batch_size();

    // Reshape according to the first image of each batch
    // on single input batches allows for inputs of varying dimension
    cv::Mat cv_img = samples_[lines_id_].first;
    CHECK(cv_img.data) << "Could not load "<<lines_id_<<" sample";
    // Use data_transformer to infer the expected blob shape from a cv_img
    vector<int> top_shape = this->data_transformer_->InferBlobShape(cv_img);
    this->transformed_data_.Reshape(top_shape);
    // Reshape batch according to the batch_size
    top_shape[0] = batch_size;
    batch->data_.Reshape(top_shape);
    
    Dtype* prefetch_data = batch->data_.mutable_cpu_data();
    Dtype* prefetch_label= batch->label_.mutable_cpu_data();

    // datum scales
    int samples_size = samples_.size();
    for(int item_id=0;item_id<batch_size;++item_id){
      // get a blob
      timer.Start();
      CHECK_GT(samples_size, lines_id_);
      cv::Mat sample = samples_[lines_id_].first;
      CHECK(sample.data) << "Could not load "<<lines_id_<<" sample";
      read_time += timer.MicroSeconds();
      timer.Start();
      // apply transformations to the image
      int offset = batch->data_.offset(item_id);
      this->transformed_data_.set_cpu_data(prefetch_data + offset);
      this->data_transformer_->Transform(sample,&(this->transformed_data_));
      trans_time += timer.MicroSeconds();

      prefetch_label[item_id] = samples_[lines_id_].second;
      // got the the next iter
      lines_id_++;
      if(lines_id_>=samples_size){
              // We have reached the end. restart from the first.
	      DLOG(INFO) << "Restarting data prefetching from start.";
	      lines_id_=0;
	      if(my_data_param.shuffle()){
		      ShuffleImages();
	      }
      }
    }
    batch_timer.Stop();
    DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << " ms.";
    DLOG(INFO) << "     Read time: " << read_time / 1000 << " ms.";
    DLOG(INFO) << "Transform time: " << trans_time / 1000 << " ms.";
}
开发者ID:xenron,项目名称:sandbox-da-Caffe,代码行数:60,代码来源:my_data_layer.cpp

示例4: main

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;
}
开发者ID:CindyLi2014,项目名称:Classes,代码行数:28,代码来源:timetest.cpp

示例5: main

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;
}
开发者ID:kimtchee,项目名称:Router,代码行数:31,代码来源:RouterRunner.cpp

示例6: main

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);

}
开发者ID:lindsaychan,项目名称:cs60-p1,代码行数:26,代码来源:timetest.cpp

示例7: main

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()
开发者ID:bmbentson,项目名称:ecs60,代码行数:56,代码来源:GradebookRunner.cpp

示例8: benchmark_ts_PLP

void benchmark_ts_PLP(tsppi::TsPpiGraph& tsppi, bool printHist=false)
{
    CPUTimer timer;

    double naive_time, fast_time;

    LOG("Start Benchmark: Naive");
    timer.start();
    std::vector<NetworKit::Partition > partitions = tsppi::algo::subgraph_PLP(tsppi.subgraphs);
    timer.stop();
    naive_time = timer.getTime();
    LOG("Time for Naive: " << timer.getTime() << " s");

    LOG("Start Benchmark: Fast");
    timer.start();
    std::vector<NetworKit::Partition > partitions_2 = tsppi::algo::subgraph_PLP_vec(tsppi.subgraphs);
    timer.stop();
    fast_time = timer.getTime();
    LOG("Time for Fast: " << timer.getTime() << " s");


    // print histogram
    if (printHist)
    {
        std::cout << "Histogram of cluster sizes for Naive:" << std::endl;
        clusterSizeHist(partitions);
        std::cout << "Histogram of cluster sizes for fast:" << std::endl;
        clusterSizeHist(partitions_2);
    }

    // print timings
    std::cout << naive_time << ";" << fast_time;
}
开发者ID:gattofrancesco,项目名称:tsppi,代码行数:33,代码来源:benchmark.cpp

示例9: CHECK

void ImageDataLayer<Dtype>::InternalThreadEntry() {
    CPUTimer batch_timer;
    batch_timer.Start();
    double read_time = 0;
    double trans_time = 0;
    CPUTimer timer;
    CHECK(this->prefetch_data_.count());
    CHECK(this->transformed_data_.count());
    Dtype* top_data = this->prefetch_data_.mutable_cpu_data();
    Dtype* top_label = this->prefetch_label_.mutable_cpu_data();
    ImageDataParameter image_data_param = this->layer_param_.image_data_param();
    const int batch_size = image_data_param.batch_size();
    const int new_height = image_data_param.new_height();
    const int new_width = image_data_param.new_width();
    const bool is_color = image_data_param.is_color();
    string root_folder = image_data_param.root_folder();

    // datum scales
    const int lines_size = lines_.size();
    for (int item_id = 0; item_id < batch_size; ++item_id) {
        // get a blob
        timer.Start();
        CHECK_GT(lines_size, lines_id_);
        cv::Mat cv_img = ReadImageToCVMat(root_folder + lines_[lines_id_].first,
                                          new_height, new_width, is_color);
        if (!cv_img.data) {
            continue;
        }
        read_time += timer.MicroSeconds();
        timer.Start();
        // Apply transformations (mirror, crop...) to the image
        int offset = this->prefetch_data_.offset(item_id);
        this->transformed_data_.set_cpu_data(top_data + offset);
        this->data_transformer_.Transform(cv_img, &(this->transformed_data_));
        trans_time += timer.MicroSeconds();

        top_label[item_id] = lines_[lines_id_].second;
        // go to the next iter
        lines_id_++;
        if (lines_id_ >= lines_size) {
            // We have reached the end. Restart from the first.
            DLOG(INFO) << "Restarting data prefetching from start.";
            lines_id_ = 0;
            if (this->layer_param_.image_data_param().shuffle()) {
                ShuffleImages();
            }
        }
    }
    batch_timer.Stop();
    DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << " ms.";
    DLOG(INFO) << "     Read time: " << read_time / 1000 << " ms.";
    DLOG(INFO) << "Transform time: " << trans_time / 1000 << " ms.";
}
开发者ID:corba777,项目名称:caffe,代码行数:53,代码来源:image_data_layer.cpp

示例10: 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()
开发者ID:zj9205,项目名称:ECS60,代码行数:52,代码来源:familyRunner.cpp

示例11: 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
开发者ID:compmix,项目名称:60,代码行数:13,代码来源:DefragRunner.cpp

示例12: CHECK

void BinaryDataLayer<Dtype>::load_batch(Batch<Dtype>* batch) {
  CPUTimer batch_timer;
  batch_timer.Start();
  double read_time = 0;
  static int time_idx = 0;
  CPUTimer timer;
  CHECK(batch->data_.count());
  ImageDataParameter image_data_param = this->layer_param_.image_data_param();
  string root_folder = image_data_param.root_folder();
  const int batch_size = this->layer_param_.image_data_param().batch_size();

  const vector<int> & top_shape = this->top_shape_;
  // Reshape batch according to the batch_size.
  batch->data_.Reshape(top_shape);

  Dtype* prefetch_data = batch->data_.mutable_cpu_data();
  Dtype* prefetch_label = batch->label_.mutable_cpu_data();

  // datum scales
  const int lines_size = lines_.size();
  const int count = top_shape[1] * top_shape[2] * top_shape[3];
  for (int item_id = 0; item_id < batch_size; ++item_id) {
      // get a blob
      timer.Start();
      CHECK_GT(lines_size, lines_id_);
      int offset = batch->data_.offset(item_id);
      int ret = ReadBinaryBlob(root_folder + lines_[lines_id_].first,
          prefetch_data + offset, count);
      read_time += timer.MicroSeconds();
      CHECK(ret == 0) << "Could not load " << lines_[lines_id_].first;

      prefetch_label[item_id] = lines_[lines_id_].second;
    // go to the next iter
    lines_id_++;
    if (lines_id_ >= lines_size) {
      // We have reached the end. Restart from the first.
      DLOG(INFO) << "Restarting data prefetching from start.";
      lines_id_ = 0;
      if (this->layer_param_.image_data_param().shuffle()) {
        ShuffleImages();
      }
    }
  }
  batch_timer.Stop();
  DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << " ms.";
  DLOG(INFO) << "     Read time: " << read_time / 1000 << " ms.";
}
开发者ID:wlgcqh,项目名称:caffe-sl,代码行数:47,代码来源:binary_data_layer.cpp

示例13: 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
开发者ID:vidushv,项目名称:60,代码行数:43,代码来源:timetest.cpp

示例14: CHECK

void DataLayer<Dtype>::InternalThreadEntry() {
  CPUTimer batch_timer;
  batch_timer.Start();
  double read_time = 0;
  double trans_time = 0;
  CPUTimer timer;
  CHECK(this->prefetch_data_.count());
  CHECK(this->transformed_data_.count());

  // Reshape according to the first datum of each batch
  // on single input batches allows for inputs of varying dimension.
  const int batch_size = this->layer_param_.data_param().batch_size();
  Datum datum;
  datum.ParseFromString(cursor_->value());
  // Use data_transformer to infer the expected blob shape from datum.
  vector<int> top_shape = this->data_transformer_->InferBlobShape(datum);
  this->transformed_data_.Reshape(top_shape);
  // Reshape prefetch_data according to the batch_size.
  top_shape[0] = batch_size;
  this->prefetch_data_.Reshape(top_shape);

  Dtype* top_data = this->prefetch_data_.mutable_cpu_data();
  Dtype* top_label = NULL;  // suppress warnings about uninitialized variables

  if (this->output_labels_) {
    top_label = this->prefetch_label_.mutable_cpu_data();
  }
  timer.Start();
  for (int item_id = 0; item_id < batch_size; ++item_id) {
    // get a datum
    Datum datum;
    datum.ParseFromString(cursor_->value());
    read_time += timer.MicroSeconds();
    timer.Start();
    // Apply data transformations (mirror, scale, crop...)
    int offset = this->prefetch_data_.offset(item_id);
    this->transformed_data_.set_cpu_data(top_data + offset);
    this->data_transformer_->Transform(datum, &(this->transformed_data_));
    // Copy label.
    if (this->output_labels_) {
      top_label[item_id] = datum.label();
    }
    trans_time += timer.MicroSeconds();
    timer.Start();
    // go to the next item.
    cursor_->Next();
    if (!cursor_->valid()) {
      DLOG(INFO) << "Restarting data prefetching from start.";
      cursor_->SeekToFirst();
    }
  }
  timer.Stop();
  batch_timer.Stop();
  DLOG(INFO) << "Prefetch batch: " << batch_timer.MilliSeconds() << " ms.";
  DLOG(INFO) << "     Read time: " << read_time / 1000 << " ms.";
  DLOG(INFO) << "Transform time: " << trans_time / 1000 << " ms.";
}
开发者ID:jliangqiu,项目名称:caffe-windows,代码行数:57,代码来源:data_layer.cpp

示例15: main

int main(int argc, char** argv)
{
  int numTrips, numFlights, numCities;
  Flight *flights, *flights2;
  Trip *trips;
  readFile(&flights, &trips, &numTrips, &numFlights,  &numCities, argv[1],
    &flights2);
  Itinerary *itineraries = new Itinerary[numTrips];
  CPUTimer ct;
  Router *router = new Router(numCities, numFlights, flights2);
  delete [] flights2;

  for(int i = 0 ; i < numTrips; i++)
    router->findRoute((const Trip*) &trips[i], &itineraries[i]);

  cout << "CPU Time: " << ct.cur_CPUTime();
  checkRoutes(flights, trips, numTrips, numFlights, itineraries, argc, argv);
 
  return 0;
} // main()
开发者ID:Skarlit,项目名称:FlightOptimizer,代码行数:20,代码来源:TripsRunner.cpp


注:本文中的CPUTimer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。