• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ timer类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: display

static void display()
{static int n;
    glClear(GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
    glLoadIdentity();
	static glShaderManager SM;
static glShader *shader;
if(!n)
{
shader=	SM.loadfromFile("vert2.txt","frag2.txt");

}

static	 timer t;
double t2=t.elapsed();
	glPointSize(23);
static	vector< particule> v;



	Repere();
	if(!n)
	{
	for(int i=0;i<2000;i++)
	{
		v.push_back(particule(45,20,8,1,i));
	}
}
	
	
	
	shader->begin();
	

int c=v.size();

	for(int i=0;i<c;i++)
	{
		

	shader->setUniform1f("p.alpha",v[i].getAlpha(),shader->GetUniformLocation("p.alpha"));
	shader->setUniform1f("p.beta",v[i].getBeta(),shader->GetUniformLocation("p.beta"));
	shader->setUniform1f("p.vIn",v[i].getInitV(),shader->GetUniformLocation("p.vIn"));
	shader->setUniform1f("p.t",t2/2,shader->GetUniformLocation("p.t"));
	shader->setUniform1f("p.start",v[i].getStart(),shader->GetUniformLocation("p.start"));
	shader->setUniform1f("p.life",v[i].getLife(),shader->GetUniformLocation("p.life"));


	v[i].draw(0,0,0);
	}


	shader->end();
	n++;
	
	if(n>2)
		n=1;

glutSwapBuffers();

}
开发者ID:jeromeCondere,项目名称:OpenGL-Confetti_canon,代码行数:60,代码来源:main.cpp


示例2: push

void push(Queue& queue, size_t n, timer& t)
{
    t.restart();
    for(size_t i=0; i<n; i++)
        queue.push();
    t.stop();
}
开发者ID:cupper,项目名称:modular_aq,代码行数:7,代码来源:maq_vs_io_service.cpp


示例3: send

    std::future<bool> send(core::const_frame frame) override
    {
        CASPAR_VERIFY(format_desc_.height * format_desc_.width * 4 == frame.image_data(0).size());

        graph_->set_value("tick-time", tick_timer_.elapsed() * format_desc_.fps * 0.5);
        tick_timer_.restart();

        caspar::timer frame_timer;

        {
            auto audio_buffer = core::audio_32_to_16(frame.audio_data());
            airsend::add_audio(air_send_.get(),
                               audio_buffer.data(),
                               static_cast<int>(audio_buffer.size()) / format_desc_.audio_channels);
        }

        {
            connected_ = airsend::add_frame_bgra(air_send_.get(), frame.image_data(0).begin());
        }

        graph_->set_text(print());
        graph_->set_value("frame-time", frame_timer.elapsed() * format_desc_.fps * 0.5);

        return make_ready_future(true);
    }
开发者ID:Julusian,项目名称:CasparCG-Server,代码行数:25,代码来源:newtek_ivga_consumer.cpp


示例4: diagonalize_bisection

int diagonalize_bisection(localized_matrix<double, MATRIX_MAJOR>& mata, localized_matrix<double, MATRIX_MAJOR>& matb,
			  double* eigvals,
			  rokko::parameters const& params, timer& timer) {
  rokko::parameters params_out;
  char jobz = 'N';  // only eigenvalues
  int dim = mata.innerSize();
  int lda = mata.outerSize();
  int ldb = matb.outerSize();
  lapack_int m;  // output: found eigenvalues
  double abstol;
  get_key(params, "abstol", abstol);
  if (abstol < 0) {
    std::cerr << "Error in diagonalize_bisection" << std::endl
	      << "abstol is negative value, which means QR method." << std::endl
	      << "To use dsygvx as bisection solver, set abstol a positive value" << std::endl;
    throw;
  }
  if (!params.defined("abstol")) {  // default: optimal value for bisection method
    abstol = 2 * LAPACKE_dlamch('S');
  }
  params_out.set("abstol", abstol);
  char uplow = get_matrix_part(params);

  lapack_int il, iu;
  double vl, vu;
  char range = get_eigenvalues_range(params, vl, vu, il, iu);

  std::vector<lapack_int> ifail(dim);
  timer.start(timer_id::diagonalize_diagonalize);
  int info;
  if(mata.is_col_major())
    info = LAPACKE_dsygvx(LAPACK_COL_MAJOR, 1, jobz, range, uplow, dim,
			  &mata(0,0), lda, &matb(0,0), ldb, vl, vu, il, iu,
			  abstol, &m, eigvals, NULL, lda, &ifail[0]);
  else
    info = LAPACKE_dsygvx(LAPACK_ROW_MAJOR, 1, jobz, range, uplow, dim,
			  &mata(0,0), lda, &matb(0,0), ldb, vl, vu, il, iu,
			  abstol, &m, eigvals, NULL, lda, &ifail[0]);
  timer.stop(timer_id::diagonalize_diagonalize);
  timer.start(timer_id::diagonalize_finalize);
  if (info) {
    std::cerr << "error at dsygvx function. info=" << info << std::endl;
    if (info < 0) {
      std::cerr << "This means that ";
      std::cerr << "the " << abs(info) << "-th argument had an illegal value." << std::endl;
    }
    exit(1);
  }
  params_out.set("m", m);
  params_out.set("ifail", ifail);
  
  if (params.get_bool("verbose")) {
    print_verbose("dsygvx (bisection)", jobz, range, uplow, vl, vu, il, iu, params_out);
  }
  timer.stop(timer_id::diagonalize_finalize);
  return info;
}
开发者ID:t-sakashita,项目名称:rokko,代码行数:57,代码来源:diagonalize_bisection_dsygvx.hpp


示例5: prepareAndRun

/**
 * Prepare and runTimer a single statement of SQL.
 */
void prepareAndRun(sqlite3 *db, string stmt, timer &t) {
	sqlite3_stmt *pStmt;

	t.start();
	checkErr(sqlite3_prepare_v2(db, stmt.c_str(), -1, &pStmt, NULL), __LINE__, db, stmt);
	while (checkErr(sqlite3_step(pStmt), __LINE__, db, stmt) == SQLITE_ROW);
	checkErr(sqlite3_finalize(pStmt), __LINE__, db, stmt);
	t.end();
}
开发者ID:,项目名称:,代码行数:12,代码来源:


示例6: main

int main()
{

	vector<recorder<timer> > stats(2);

	for(int i = 0; i < 2; i++)
		stats[i].reset();

	int size = 1000000;
	Resistive gh(6);
	//for(int i =0; i < size; i++)
	//	gh.addEdge(i, i+1, i+1);

	//for(int i = 0; i < size; i++)
	//	gh.addEdge(0, 1, i+1);

//	for(int i = 0; i < size; i++) {
//		for(int jazz = 0; jazz < 1000; jazz++)
//			gh.addEdge(i, i+1, 100);
//	}

	gh.addEdge(0, 1, 2);	
   	gh.addEdge(0, 1, 8);	
   	gh.addEdge(0, 5, 10);	
   	gh.addEdge(0, 2, 20);	
   	gh.addEdge(0, 2, 30);	
   	gh.addEdge(0, 2, 60);	
   	gh.addEdge(1, 3, 9);	
   	gh.addEdge(1, 3, 6);	
   	gh.addEdge(2, 4, 90);	
   	gh.addEdge(3, 5, 3);	
   	gh.addEdge(4, 5, 3);	
   	gh.addEdge(4, 5, 100);	
   	gh.addEdge(4, 5, 15);	
	
    gh.printGraph();

	timer1.restart();
	double ans = gh.traverse(0, 5);
   	timer1.stop();	
	stats[0].record(timer1);
   	cout << "-----------------" << endl; 
    
	gh.printGraph();
 
    // print the adjacency list representation of the above graph
	cout << endl << "TIME: ";
	stats[0].report(cout);

	cout << endl << ans << endl;
	double test = 0;
	for(int n = 1; n <= size; n++)
		test += n;
 
    return 0;
}
开发者ID:emersoncloud,项目名称:capstone,代码行数:56,代码来源:main.cpp


示例7:

 ~scoped_timer()
 {
   if (enabled) {
     const double x = t.lap_ms();
     std::cerr << "timed region `" << region << "' took " << x << " ms" << std::endl;
   }
 }
开发者ID:stephentu,项目名称:community,代码行数:7,代码来源:timer.hpp


示例8: after_iteration

 /**
  * Called after an iteration has finished.
  */
 void after_iteration(int iteration, graphchi_context &ginfo) {
   logstream(LOG_DEBUG)<<mytimer.current_time() << "iteration: " << iteration << " changes: " << changes << std::endl;
   if (changes == 0)
     ginfo.set_last_iteration(iteration);
   changes = 0;
   iter++;
 }
开发者ID:JustgoFlyme,项目名称:graphchi,代码行数:10,代码来源:bond_percolation.cpp


示例9: socket

bool ripng_router::check_startup() {
	if (!router::check_startup())
		return false;

	int sock = socket(PF_INET6, SOCK_DGRAM, 0);
	if (sock < 0)
		return false;

	sockaddr_in6 local;
	memset(&local, 0, sizeof(local));
	local.sin6_family = AF_INET6;
	local.sin6_port = htons(522);

	if (bind(sock, (sockaddr *)&local, sizeof(local)) < 0) {
		if (should_log(WARNING))
			log().perror("Failed to bind");
		close(sock);
		return false;
	}

	if (!m_sock.register_fd(sock)) {
		close(sock);
		return false;
	}

	if (!m_sock.enable_mc_loop(false))
		return false;

	g_mrd->mrib().install_listener(this);

	m_garbcol_timer.start();

	return true;
}
开发者ID:Distrotech,项目名称:mrd6,代码行数:34,代码来源:ripng.cpp


示例10: measure

            results measure(const Implementation& implementation) const
            {
                // Run a few times in an attempt to pull code pages into CPU
                // cache
                execute(implementation);
                execute(implementation);

                timer::duration elapsed{0};
                unsigned result{0};
                {
                    const timer time;
                    result = execute(implementation);
                    elapsed = time.elapsed();
                }
                return {elapsed, result};
            }
开发者ID:vtnerd,项目名称:prima,代码行数:16,代码来源:run.hpp


示例11: main

int main(int argc, const char ** argv) {
  print_copyright();

  /* CE_Graph initialization will read the command line 
     arguments and the configuration file. */
  CE_Graph_init(argc, argv);

  /* Metrics object for keeping track of performance counters
     and other information. Currently required. */
  metrics m("item-cf2");    
  /* Basic arguments for application */
  min_allowed_intersection = get_option_int("min_allowed_intersection", min_allowed_intersection);

  distance_metric          = get_option_int("distance", JACCARD_WEIGHT);
      if (distance_metric != JACCARD_WEIGHT)
    logstream(LOG_FATAL)<<"--distance_metrix=XX should be one of:9= JACCARD_WEIGHT" << std::endl;
  debug                    = get_option_int("debug", 0);
  parse_command_line_args();

  //if (distance_metric != JACKARD && distance_metric != AA && distance_metric != RA)
  //  logstream(LOG_FATAL)<<"Wrong distance metric. --distance_metric=XX, where XX should be either 0) JACKARD, 1) AA, 2) RA" << std::endl;  

  mytimer.start();
  int nshards          = convert_matrixmarket<EdgeDataType>(training, 0, 0, 3, TRAINING, true);

  assert(M > 0 && N > 0);

  //initialize data structure which saves a subset of the items (pivots) in memory
  adjcontainer = new adjlist_container();

  /* Run */
  ItemDistanceProgram program;
  CE_Graph_engine<VertexDataType, EdgeDataType> engine(training, nshards, true, m); 
  set_engine_flags(engine);

  //open output files as the number of operating threads
  out_files.resize(number_of_omp_threads());
  for (uint i=0; i< out_files.size(); i++){
    char buf[256];
    sprintf(buf, "%s.out%d", training.c_str(), i);
    out_files[i] = open_file(buf, "w");
  }

  //run the program
  engine.run(program, niters);

  /* Report execution metrics */
  if (!quiet)
    metrics_report(m);
  
  std::cout<<"Total item pairs compared: " << item_pairs_compared << " total written to file: " << written_pairs << std::endl;

  for (uint i=0; i< out_files.size(); i++)
    fclose(out_files[i]);

  std::cout<<"Created output files with the format: " << training << ".outXX, where XX is the output thread number" << std::endl; 

  return 0;
}
开发者ID:carriercomm,项目名称:DPDK-Graph,代码行数:59,代码来源:itemcf3.cpp


示例12: main

int main(int argc, const char ** argv) {
    print_copyright();

    /* GraphChi initialization will read the command line
       arguments and the configuration file. */
    graphchi_init(argc, argv);

    /* Metrics object for keeping track of performance counters
       and other information. Currently required. */
    metrics m("itemsim2rating2");

    /* Basic arguments for application */
    min_allowed_intersection = get_option_int("min_allowed_intersection", min_allowed_intersection);
    debug                    = get_option_int("debug", 0);
    parse_command_line_args();
    std::string similarity   = get_option_string("similarity", "");
    if (similarity == "")
        Rcpp::Rcerr<<"Missing similarity input file. Please specify one using the --similarity=filename command line flag" << std::endl;
    undirected               = get_option_int("undirected", 1);
    Q                        = get_option_float("Q", Q);
    K 			   = get_option_int("K");

    mytimer.start();
    vec unused;
    int nshards          = convert_matrixmarket_and_item_similarity<edge_data>(training, similarity, 3, unused);

    assert(M > 0 && N > 0);

    //initialize data structure which saves a subset of the items (pivots) in memory
    adjcontainer = new adjlist_container();

    //array for marking which items are conected to the pivot items via users.
    relevant_items = new bool[N];

    /* Run */
    ItemDistanceProgram program;
    graphchi_engine<VertexDataType, edge_data> engine(training, nshards, true, m);
    set_engine_flags(engine);

    out_file = open_file((training + "-rec").c_str(), "w");

    //run the program
    engine.run(program, niters);

    /* Report execution metrics */
    if (!quiet)
        metrics_report(m);

    Rcpp::Rcout<<"Total item pairs compared: " << item_pairs_compared << " total written to file: " << written_pairs << std::endl;

    if (zero_edges)
        Rcpp::Rcout<<"Found: " << zero_edges<< " user edges with weight zero. Those are ignored." <<std::endl;

    delete[] relevant_items;
    fclose(out_file);
    return 0;
}
开发者ID:thirdwing,项目名称:RcppGraphChi,代码行数:57,代码来源:itemsim2rating.cpp


示例13: timer

		timer(const timer& aOther) :
			iOwnerThread(aOther.iOwnerThread),
			iTimerObject(aOther.iOwnerThread.io_service()),
			iDuration_ms(aOther.iDuration_ms), 
			iWaiting(false), 
			iCancelling(false)
		{
			if (aOther.waiting())
				again();
		}
开发者ID:alphafork,项目名称:Library-signal-slot-benchmarks,代码行数:10,代码来源:timer.hpp


示例14: training_rmse

void training_rmse(int iteration, graphchi_context &gcontext){
    last_training_rmse = dtraining_rmse;
    dtraining_rmse = 0;
#pragma omp parallel for reduction(+:dtraining_rmse)
    for (int i=0; i< (int)M; i++){
      dtraining_rmse += latent_factors_inmem[i].rmse;
    }
    dtraining_rmse = sqrt(dtraining_rmse / pengine->num_edges());
    std::cout<< std::setw(10) << mytimer.current_time() << ") Iteration: " << std::setw(3) <<iteration<<" Training RMSE: " << std::setw(10)<< dtraining_rmse;
 }
开发者ID:,项目名称:,代码行数:10,代码来源:


示例15: read_reply

int shrimp_gateway_impl::read_reply() {

    m_timer_status = 0;
    m_io_timer.start();
    char* r = new char[10];
    int rd = m_shrimp.Readv(r, 1, &m_timer_status);
    //printf("r: %i\n", r[0]);
    m_reply = r[0];
    //printf("byte read %i\n", rd);
    return rd;
}
开发者ID:chenbk85,项目名称:alcordev,代码行数:11,代码来源:shrimp_gateway_impl.cpp


示例16: iIoTask

	timer::timer(const timer& aOther) :
		iIoTask(aOther.iIoTask),
		iHandlerProxy(new handler_proxy(*this)),
		iTimerObject(aOther.iIoTask.timer_io_service().native_object()),
		iDuration_ms(aOther.iDuration_ms), 
		iEnabled(aOther.iEnabled),
		iWaiting(false), 
		iInReady(false)
	{
		if (aOther.waiting())
			again();
	}
开发者ID:NoAvailableAlias,项目名称:signal-slot-benchmarks,代码行数:12,代码来源:timer.cpp


示例17: update

  /**
   *  Vertex update function - computes the least square step
   */
  void update(graphchi_vertex<VertexDataType, EdgeDataType> &vertex, graphchi_context &gcontext) {

  if (vertex.id() >= M)
    return;

  vertex_data & vdata = latent_factors_inmem[vertex.id()];
  int howmany = N*knn_sample_percent;
  assert(howmany > 0 );
  vec distances = vec::Zero(howmany);
  ivec indices = ivec(howmany);
  for (int i=0; i< howmany; i++){
    indices[i]= -2;
  }
  std::vector<bool> curratings;
  curratings.resize(N);
  for(int e=0; e < vertex.num_edges(); e++) {
  //no need to calculate this rating since it is given in the training data reference
    curratings[vertex.edge(e)->vertex_id() - M] = true;
  }
   if (knn_sample_percent == 1.0){
     for (uint i=M; i< M+N; i++){
        if (curratings[i-M])
          continue;
        vertex_data & other = latent_factors_inmem[i];
        double dist;
        als_predict(vdata, other, 0, dist); 
        indices[i-M] = i-M;
        distances[i-M] = dist;
     }
  }
  else for (int i=0; i<howmany; i++){
        int random_other = ::randi(M, M+N-1);
        vertex_data & other = latent_factors_inmem[random_other];
        double dist;
        als_predict(vdata, other, 0, dist); 
        indices[i-M] = i-M;
        distances[i-M] = dist;
   }
  
  vec out_dist(num_ratings);
  ivec indices_sorted = reverse_sort_index2(distances, indices, out_dist, num_ratings);
  assert(indices_sorted.size() <= num_ratings);
  assert(out_dist.size() <= num_ratings);
  vdata.ids = indices_sorted;
  vdata.ratings = out_dist;
  if (debug)
    printf("Closest is: %d with distance %g\n", (int)vdata.ids[0], vdata.ratings[0]);

  if (vertex.id() % 1000 == 0)
    printf("Computing recommendaitons for user %d at time: %g\n", vertex.id()+1, mytimer.current_time());
  
  
  }
开发者ID:michaelkook,项目名称:paragraph,代码行数:56,代码来源:rating.cpp


示例18: memcpy

int shrimp_gateway_impl::send_command(const shrimp_command_t& command) {

    m_timer_status = 0;
    m_io_timer.start();

    unsigned char* cmd = new unsigned char[3];
    memcpy(cmd, command.to_buf(), command.get_size());
    //printf("%i %i %i", cmd[0], cmd[1], cmd[2]);

    int wd = m_shrimp.Writev(command.to_buf(), command.get_size(), &m_timer_status);
    //printf("bytes sent %i\n", wd);
    return wd;
}
开发者ID:chenbk85,项目名称:alcordev,代码行数:13,代码来源:shrimp_gateway_impl.cpp


示例19: Progress

/*!
  Progress(theTimer, nodenum, numnodes, thePercent, 5, theTime, 60, "Reading dumpfile"); 
 if either delta is exceeded, increase oPercent & oTime and report the progress
 return 1 if something is printed out, else return 0 
*/
int Progress(timer &iTimer, double iNum, double iMax, 
             double &oPercent, double iPercentDelta, 
             double &oTime, double iTimeDelta,  string iMsg) {
  double percent = iNum/iMax*100.0;
  double newtime = iTimer.elapsed_time();
  if (iNum == iMax || percent - oPercent > iPercentDelta || newtime-oTime > iTimeDelta) {      
    double remaining = (iMax-iNum)/(iNum!=0?iNum:1)*newtime;
    double persec= iNum/newtime;
    char msg[4096]; 
    sprintf(msg, "\r%s: %g%%;  %g/%g items, %g secs, %g/sec, left: %g", /*datestring(), */iMsg.c_str(), percent, iNum, iMax, newtime, persec, remaining);
    cerr << msg << flush;
    oPercent=percent;
    oTime=newtime; 
    return 1; 
  }
  return 0; 
}
开发者ID:,项目名称:,代码行数:22,代码来源:


示例20: update

  /**
   *  Vertex update function.
   */
  void update(CE_Graph_vertex<VertexDataType, EdgeDataType> &v, CE_Graph_context &gcontext) {
    if (debug)
      printf("Entered iteration %d with %d - edges %d\n", gcontext.iteration, v.id(), v.num_edges());

    /* even iteration numbers:
     * 1) load a subset of items into memory (pivots)
     * 2) Find which subset of items needs to compared to the users
     */
    if (gcontext.iteration % 2 == 0) {
      if (adjcontainer->is_pivot(v.id())){
        adjcontainer->load_edges_into_memory(v);         
        if (debug)
          printf("Loading pivot %d intro memory\n", v.id());
      }
    }
    else {

      for (vid_t i=adjcontainer->pivot_st; i< adjcontainer->pivot_en; i++){
        //since metric is symmetric, compare only to pivots which are smaller than this item id
        if (i >= v.id())
          continue;
        
        dense_adj &pivot_edges = adjcontainer->adjs[i - adjcontainer->pivot_st];
        //pivot is not connected to this item, continue
        if (get_val(pivot_edges.edges, v.id()) == 0)
            continue;

        double dist = adjcontainer->calc_distance(v, i, distance_metric);
        item_pairs_compared++;
        if (item_pairs_compared % 1000000 == 0)
          logstream(LOG_INFO)<< std::setw(10) << mytimer.current_time() << ")  " << std::setw(10) << item_pairs_compared << " pairs compared " << std::endl;
        if (debug)
          printf("comparing %d to pivot %d distance is %lg\n", i+ 1, v.id() + 1, dist);
        if (dist != 0){
          fprintf(out_files[omp_get_thread_num()], "%u %u %.12lg\n", v.id()+1, i+1, (double)dist);//write item similarity to file
          //where the output format is: 
          //[item A] [ item B ] [ distance ] 
          written_pairs++;
        }
      }
    }//end of iteration % 2 == 1
  }//end of update function
开发者ID:carriercomm,项目名称:DPDK-Graph,代码行数:45,代码来源:itemcf3.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ timerLib类代码示例发布时间:2022-05-31
下一篇:
C++ time_type类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap