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

C++ elapsed_time函数代码示例

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

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



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

示例1: on_ctrl_change

    virtual void on_ctrl_change()
    {
        if(m_test.status())
        {
            on_draw();
            update_window();
            m_test.status(false);

            start_timer();
            int i;
            for(i = 0; i < 1000; i++)
            {
                draw_aliased();
            }
            double t1 = elapsed_time();

            start_timer();
            for(i = 0; i < 1000; i++)
            {
                draw_anti_aliased();
            }
            double t2 = elapsed_time();

            update_window();
            char buf[100];
            sprintf(buf, "Time Aliased=%.2fms Time Anti-Aliased=%.2fms", t1, t2);
            message(buf);
        }
    }
开发者ID:GordonSmith,项目名称:agg,代码行数:29,代码来源:rasterizers.cpp


示例2: encode

// encode function calls
void encode(const char* type, const char* infilename, const char* outfilename)
{
	infile = fopen(infilename, "r+b");
	outfile = fopen(outfilename, "w+b");

	printf("filename     %s\n", infilename);
	//printf("size         %d\n", get_file_size(infilename));
	printf("----\n");
	if ( strcmp(type, "HUFF") == 0 )
	{
		start_timer();
		huff(infile, outfile);
		printf("t-cmprss     %.2f\n", elapsed_time());
	}
	else if ( strcmp(type, "LZ1") == 0 )
	{
		start_timer();
		lz1(infile, outfile);
		printf("t-cmprss     %.2f\n", elapsed_time());
	}
	else if ( strcmp(type, "LZ2") == 0 )
	{
		start_timer();
		lz2(infile, outfile);
		printf("t-cmprss     %.2f\n", elapsed_time());
	}
	else
		printf("Error: unknown encode function call");
}
开发者ID:nashn,项目名称:cs165projects,代码行数:30,代码来源:utility.c


示例3: on_ctrl_change

    virtual void on_ctrl_change()
    {
        if(m_benchmark.status())
        {
            int i;
            on_draw();
            update_window();

            scanline_rasterizer ras;

            pixfmt pixf(rbuf_window());
            base_renderer rb(pixf);
            solid_renderer solid(rb);
            draft_renderer draft(rb);

            char buf[256];
            if(m_draft.status())
            {
                start_timer();
                for(i = 0; i < 10; i++)
                {
                    draw_scene(ras, solid, draft);
                }
                sprintf(buf, "%3.3f milliseconds", elapsed_time());
            }
            else
            {
                double times[5];
                for(m_draw = 0; m_draw < 4; m_draw++)
                {
                    start_timer();
                    for(i = 0; i < 10; i++)
                    {
                        draw_scene(ras, solid, draft);
                    }
                    times[m_draw] = elapsed_time();
                }
                m_draw = 3;

                times[4]  = times[3];
                times[3] -= times[2];
                times[2] -= times[1];
                times[1] -= times[0];
            
                FILE* fd = fopen(full_file_name("benchmark"), "a");
                fprintf(fd, "%10.3f %10.3f %10.3f %10.3f %10.3f\n", 
                            times[0], times[1], times[2], times[3], times[4]);
                fclose(fd);
            

                sprintf(buf, "  pipeline  add_path         sort       render       total\n"
                             "%10.3f %10.3f %10.3f %10.3f %10.3f", 
                        times[0], times[1], times[2], times[3], times[4]);
            }
            message(buf);

            m_benchmark.status(false);
            force_redraw();
        }
    }
开发者ID:Bashakov,项目名称:agg,代码行数:60,代码来源:graph_test.cpp


示例4: random_bench

static void
random_bench (int very_strong)
{
  char buf[128];
  int i;

  printf ("%-10s", "random");

  if (!very_strong)
    {
      start_timer ();
      for (i=0; i < 100; i++)
        gcry_randomize (buf, sizeof buf, GCRY_STRONG_RANDOM);
      stop_timer ();
      printf (" %s", elapsed_time ());
    }

  start_timer ();
  for (i=0; i < 100; i++)
    gcry_randomize (buf, 8,
                    very_strong? GCRY_VERY_STRONG_RANDOM:GCRY_STRONG_RANDOM);
  stop_timer ();
  printf (" %s", elapsed_time ());

  putchar ('\n');
  if (verbose)
    gcry_control (GCRYCTL_DUMP_RANDOM_STATS);
}
开发者ID:Greenchik,项目名称:libgcrypt,代码行数:28,代码来源:benchmark.c


示例5: get_time

void t_move_missile::on_idle()
{
    t_uint32 new_time = get_time();

    // update animation (if any)
    if (elapsed_time( new_time, m_last_update_time ) >= m_delay )
    {
        int frame = m_missile.get_current_frame_num();

        frame++;
        if (frame >= m_missile.get_frame_count())
            frame = 0;
        m_battlefield.set_current_frame_num( m_missile, frame );
        m_last_update_time = new_time;
    }

    t_map_point_3d position;
    t_uint32       next_time = get_next_time() - get_delay();
    int			   skip_limit = 1;

    // move missile forward one space
    while (elapsed_time( new_time, next_time ) >= 0 && skip_limit-- > 0 )
    {
        next_time += get_delay();
        if (m_distance_left <= 0)
        {
            t_idle_ptr reference = this;

            suspend_idle_processing();
            m_battlefield.remove_object( &m_missile );
            animation_ended();
            m_end_handler( m_attacker, m_target_position );
            return;
        }

        t_map_point_3d delta;
        int            distance;

        // limit distance moved to distance left
        position = m_missile.get_position();
        distance = m_move_distance;
        if (distance > m_distance_left)
            distance = m_distance_left;
        m_distance_left -= distance;
        // add distance to accumulator
        m_sum += m_delta * distance;
        // find integer portion of moved distance
        delta = m_sum / m_distance;
        position += delta;
        m_sum -= delta * m_distance;
        // calculate parabolic arc
        if (m_is_parabolic)
        {
            position.height += m_vertical_velocity - k_gravity;
            m_vertical_velocity -= k_gravity << 1;
        }
    }
    set_next_time( next_time );
    m_battlefield.move_object( m_missile, position );
}
开发者ID:sundoom,项目名称:sunstudio,代码行数:60,代码来源:move_missile.cpp


示例6: process_whale

void process_whale(int is_male, int id) {
	int num_males, num_females;
	
	pthread_mutex_lock(&mutex);
	if (is_male) {
		male_queue[male_position++] = id;
		sem_post(&male_avail);
	}
	else {
		female_queue[female_position++] = id;
		sem_post(&female_avail);
	}

	sem_getvalue(&male_avail, &num_males);
	sem_getvalue(&female_avail, &num_females);

	pthread_mutex_unlock(&mutex);

	int this_sex = (is_male) ? num_males : num_females;
	int opposite_sex = (is_male) ? num_females : num_males;

	if (opposite_sex) {
		if (!mate_pending) {
			pthread_mutex_lock(&mutex);
			mate_pending++;
			LOCKED_PRINTF("(t=%f) %d: %s\n", elapsed_time(), male_queue[male_head], "Found Mate");
			LOCKED_PRINTF("(t=%f) %d: %s\n", elapsed_time(), female_queue[female_head], "Found Mate");
			pthread_mutex_unlock(&mutex);
		}

		if (this_sex > 1) { // matchmaker
			while (mate_pending) {
				pthread_mutex_lock(&mutex);
				LOCKED_PRINTF("(t=%f) %d: %s\n", elapsed_time(), id, "Became MatchMaker");

				sem_wait(&male_avail);
				sem_wait(&female_avail);

				LOCKED_PRINTF("(t=%f) %d: %s\n", elapsed_time(), male_queue[male_head], "Mated");
				LOCKED_PRINTF("(t=%f) %d: %s\n", elapsed_time(), female_queue[female_head], "Mated");
				
				mate_pending--;

				male_head++;
				female_head++;
				pthread_mutex_unlock(&mutex);
			}

			pthread_mutex_lock(&mutex);
			sem_getvalue(&male_avail, &num_males);
			sem_getvalue(&female_avail, &num_females);
			pthread_mutex_unlock(&mutex);
		}
	}
}
开发者ID:walshycakes,项目名称:cs4414,代码行数:55,代码来源:whales.c


示例7: perform_rendering

    void perform_rendering(Scanline &sl, Ras &ras, Ren &ren, Clp &clp)
    {
        if(m_operation.cur_item() > 0)
        {
            ras.reset();
            switch(m_operation.cur_item())
            {
                case 1: clp.operation(agg::clipper_or);           break;
                case 2: clp.operation(agg::clipper_and);          break;
                case 3: clp.operation(agg::clipper_xor);          break;
                case 4: clp.operation(agg::clipper_a_minus_b);    break;
                case 5: clp.operation(agg::clipper_b_minus_a);    break;
            }
            agg::conv_poly_counter<Clp> counter(clp);


            start_timer();
            counter.rewind(0);
            double t1 = elapsed_time();

            ras.reset();
            double x;
            double y;
            unsigned cmd;
            start_timer();
            while(!agg::is_stop(cmd = counter.vertex(&x, &y)))
            {
                ras.add_vertex(x, y, cmd);
            }

            ren.color(agg::rgba(0.5, 0.0, 0, 0.5));
            agg::render_scanlines(ras, sl, ren);
            double t2 = elapsed_time();

            char buf[100];
            sprintf_s(buf, "Contours: %d      Points: %d", counter.m_contours, counter.m_points);
            agg::gsv_text txt;
            agg::conv_stroke<agg::gsv_text> txt_stroke(txt);
            txt_stroke.width(1.5);
            txt_stroke.line_cap(agg::round_cap);
            txt.size(10.0);
            txt.start_point(250, 5);
            txt.text(buf);
            ras.add_path(txt_stroke);
            ren.color(agg::rgba(0.0, 0.0, 0.0));
            agg::render_scanlines(ras, sl, ren);

            sprintf_s(buf, "Clipper=%.3fms Render=%.3fms", t1, t2);
            txt.start_point(250, 20);
            txt.text(buf);
            ras.add_path(txt_stroke);
            ren.color(agg::rgba(0.0, 0.0, 0.0));
            agg::render_scanlines(ras, sl, ren);
        }
    }
开发者ID:asheikh91,项目名称:repsnapper,代码行数:55,代码来源:clipper_test.cpp


示例8: benchmarks_ssh_latency

/** @internal
 * @brief Calculates the RTT of the host with SSH channel operations, and
 * returns the average of the calculated RTT.
 * @param[in] session active SSH session to test.
 * @param[out] average average RTT in milliseconds.
 * @returns 0 on success, -1 if there is an error.
 */
int benchmarks_ssh_latency(ssh_session session, float *average){
  float times[3];
  struct timestamp_struct ts;
  int i;
  ssh_channel channel;
  channel=ssh_channel_new(session);
  if(channel==NULL)
    goto error;
  if(ssh_channel_open_session(channel)==SSH_ERROR)
    goto error;

  for(i=0;i<3;++i){
    timestamp_init(&ts);
    if(ssh_channel_request_env(channel,"TEST","test")==SSH_ERROR &&
        ssh_get_error_code(session)==SSH_FATAL)
      goto error;
    times[i]=elapsed_time(&ts);
  }
  ssh_channel_close(channel);
  ssh_channel_free(channel);
  channel=NULL;
  printf("Times : %f ms ; %f ms ; %f ms\n", times[0], times[1], times[2]);
  *average=(times[0]+times[1]+times[2])/3;
  return 0;
error:
  fprintf(stderr,"Error calculating SSH latency : %s\n",ssh_get_error(session));
  if(channel)
    ssh_channel_free(channel);
  return -1;
}
开发者ID:FuckingCoder,项目名称:libssh,代码行数:37,代码来源:latency.c


示例9:

initialize::~initialize() {
  if (!quiet) master_printf("\nElapsed run time = %g s\n", elapsed_time());
#ifdef HAVE_MPI
  end_divide_parallel();
  MPI_Finalize();
#endif
}
开发者ID:Arthur-Thijssen,项目名称:MEEP-actt,代码行数:7,代码来源:mympi.cpp


示例10: perform_rendering

    void perform_rendering(VertexSource& vs)
    {
        pixfmt_type pixf(rbuf_window());

        typedef agg::pixfmt_amask_adaptor<pixfmt_type, alpha_mask_type> pixfmt_amask_type;
        typedef agg::renderer_base<pixfmt_amask_type>                   amask_ren_type;


        pixfmt_amask_type pixfa(pixf, m_alpha_mask);
        amask_ren_type rbase(pixfa);
        agg::renderer_scanline_aa_solid<amask_ren_type> ren(rbase);

        ren.color(agg::rgba(0.5, 0.0, 0, 0.5));

        start_timer();
        m_ras.reset();
        m_ras.add_path(vs);
        agg::render_scanlines(m_ras, m_sl, ren);
        double t1 = elapsed_time();


        char buf[100];
        sprintf(buf, "Render with AlphaMask: %.3fms", t1);
        draw_text(250, 5, buf);
    }
开发者ID:GordonSmith,项目名称:agg,代码行数:25,代码来源:alpha_mask3.cpp


示例11: generate_alpha_mask

    template<class VertexSource> void generate_alpha_mask(VertexSource& vs)
    {
        unsigned cx = (unsigned)width();
        unsigned cy = (unsigned)height();

        delete [] m_alpha_buf;
        m_alpha_buf = new unsigned char[cx * cy];
        m_alpha_mask_rbuf.attach(m_alpha_buf, cx, cy, cx);

        typedef agg::renderer_base<agg::pixfmt_gray8> ren_base;
        typedef agg::renderer_scanline_aa_solid<ren_base> renderer;

        agg::pixfmt_gray8 pixf(m_alpha_mask_rbuf);
        ren_base rb(pixf);
        renderer ren(rb);

        start_timer();
        if(m_operation.cur_item() == 0)
        {
            rb.clear(agg::gray8(0));
            ren.color(agg::gray8(255));
        }
        else 
        {
            rb.clear(agg::gray8(255));
            ren.color(agg::gray8(0));
        }
        m_ras.add_path(vs);
        agg::render_scanlines(m_ras, m_sl, ren);
        double t1 = elapsed_time();

        char buf[100];
        sprintf(buf, "Generate AlphaMask: %.3fms", t1);
        draw_text(250, 20, buf);
    }
开发者ID:GordonSmith,项目名称:agg,代码行数:35,代码来源:alpha_mask3.cpp


示例12: VERBOSE

/***
 * Print out an optional message followed by the current timer timing.
 */
void Timer::check(const char* msg)
{
  // Print an optional message, something like "Checking timer t";
  if (msg) VERBOSE(0, msg << " : ");

  VERBOSE(0, "[" << (running ? elapsed_time() : 0) << "] seconds\n");
}
开发者ID:MistSC,项目名称:kaldi-trunk,代码行数:10,代码来源:timer.cpp


示例13: do_powm

static void
do_powm ( const char *n_str, const char *e_str, const char *m_str)
{
  gcry_mpi_t e, n, msg, cip;
  gcry_error_t err;
  int i;

  err = gcry_mpi_scan (&n, GCRYMPI_FMT_HEX, n_str, 0, 0);
  if (err) BUG ();
  err = gcry_mpi_scan (&e, GCRYMPI_FMT_HEX, e_str, 0, 0);
  if (err) BUG ();
  err = gcry_mpi_scan (&msg, GCRYMPI_FMT_HEX, m_str, 0, 0);
  if (err) BUG ();

  cip = gcry_mpi_new (0);

  start_timer ();
  for (i=0; i < 1000; i++)
    gcry_mpi_powm (cip, msg, e, n);
  stop_timer ();
  printf (" %s", elapsed_time ()); fflush (stdout);
/*    { */
/*      char *buf; */

/*      if (gcry_mpi_aprint (GCRYMPI_FMT_HEX, (void**)&buf, NULL, cip)) */
/*        BUG (); */
/*      printf ("result: %s\n", buf); */
/*      gcry_free (buf); */
/*    } */
  gcry_mpi_release (cip);
  gcry_mpi_release (msg);
  gcry_mpi_release (n);
  gcry_mpi_release (e);
}
开发者ID:Greenchik,项目名称:libgcrypt,代码行数:34,代码来源:benchmark.c


示例14: glClearColor

void obj::scene::initialize() {
    glClearColor(.1, .16, .19, 0);
    glClearDepth(1.0);

    GLfloat light_position[] = { 1.0, 1.0, 1.0, 0.0 };
    GLfloat light_specular[] = { 1.0, 1.0, 1.0, 1.0 };
    GLfloat light_diffuse[]  = { 1.0, 1.0, 1.0, 1.0 };
    glShadeModel(GL_SMOOTH);

    glLightfv(GL_LIGHT0, GL_POSITION, light_position);
    glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
    glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);

    glEnable(GL_DEPTH_TEST);
    glEnable(GL_LIGHTING);
    glEnable(GL_LIGHT0);
    glEnable(GL_COLOR_MATERIAL);

    glLineWidth(3);
    glPointSize(20);

    glScalef(2, 2, 5);

    glutSetCursor(GLUT_CURSOR_CROSSHAIR);

    current_time = timebase = elapsed_time();

    camera = new obj::camera(90);

    reset_camera();
}
开发者ID:fuadsaud,项目名称:objviewer,代码行数:31,代码来源:scene.cpp


示例15: benchmark

void benchmark(Graf& cos, int poczatek, int koniec, std::ostream& out) {

	std::chrono::time_point<std::chrono::system_clock> start, end;
	std::chrono::duration<double> elapsed_time(0);

	start = std::chrono::system_clock::now();
	auto list = depth_first(cos, poczatek, koniec);
	end = std::chrono::system_clock::now();
	elapsed_time = end-start;
	out << "DEPTH-FIRST time: " << elapsed_time.count()  << "s. ";
	for( auto t : list ) std::cerr << t << " -> "; std::cerr << "\n";


	start = std::chrono::system_clock::now();
	list = breadth_first(cos, poczatek, koniec);
	end = std::chrono::system_clock::now();
	elapsed_time = end-start;
	out << "BREADTH-FIRST time: " << elapsed_time.count()  << "s. ";
	for( auto t : list ) std::cerr << t << " -> "; std::cerr << "\n";

	start = std::chrono::system_clock::now();
	list = a_star(cos, poczatek, koniec );
	end = std::chrono::system_clock::now();
	elapsed_time = end-start;
	out << "A* time: " << elapsed_time.count()  << "s. ";
	for( auto t : list ) std::cerr << t << " -> "; std::cerr << "\n";

}
开发者ID:martynabandura,项目名称:pamsi2,代码行数:28,代码来源:benchmark.cpp


示例16: remaining_time

 double remaining_time(
    double dist_thresh=Config::get_var_dbl("GEST_STARTUP_DIST_THRESH",10.0,true)
    ) const {
    // Time spent after the "startup" period within the given
    // distance of the 1st point.
    return elapsed_time() - startup_time(dist_thresh);
 }
开发者ID:QuLogic,项目名称:jot-lib,代码行数:7,代码来源:gesture.hpp


示例17: main

main(){
  struct timeval start,end;
  gettimeofday(&start, 0);

  int t,i,T,N,C,*P,*W;

  const int num_thread = 2;

  scanf("%d",&T);
  for(t=0;t<T;++t){
    scanf("%d",&C);
    scanf("%d",&N);

    P = (int*)malloc(sizeof(int) * N);
    W = (int*)malloc(sizeof(int) * N);

    for(i=0;i<N;++i){
      scanf("%d %d",&W[i],&P[i]);
    }

    printf("%d\n",p_knapsack(num_thread,P,W,N,C));
  }

  gettimeofday(&end, 0);
  printf("%lf\n", elapsed_time(start,end));
}
开发者ID:osa9,项目名称:knapsack,代码行数:26,代码来源:n4.c


示例18: main

int main(int argc, char *argv[]) 
{
       ticks_per_second = sysconf(_SC_CLK_TCK);

        if((argc !=2 && argc !=3)  || (argv[1][0] == '-' && argv[1][1] == 'h')){
           printf("usage: ./MixBcd CNF formula [<output>]\n");
           return 0;
        }
        printf("c MixBcd: Fast blocked clause decomposition by Chen, July 1, 2015\n");
    
        fileName = argv[1];
        if (argc == 3) output = fopen(argv[2], "w");
        else output = stdout;

	buildSignalHandler();

	readCNFfile();
	value = (int*) malloc(sizeof(int) * (nVars + 1));
        lookup_Mem();
        MixDecompose(0);

	double totalTime = elapsed_time();
	printf("c %-30s: %-8.3fsec\n", "final time", totalTime);
	return 0;
}
开发者ID:EgoIncarnate,项目名称:MixBcd,代码行数:25,代码来源:MixBcd.c


示例19: on_idle

    void on_idle()
    {
        if(m_run.status())
        {
            if(m_cur_angle < 360.0)
            {
                m_cur_angle += m_step.value();
                copy_img_to_img(1, 0);
#ifdef AGG_ACCURATE_TIME
                start_timer();
#endif
                transform_image(m_step.value());
#ifdef AGG_ACCURATE_TIME
                m_time2 += elapsed_time();
#endif
                m_num_steps++;
            }
            else
            {
                m_cur_angle = 0.0;
#ifndef AGG_ACCURATE_TIME
                m_time2 = clock();
#endif
                wait_mode(true);
                m_run.status(false);
            }
            force_redraw();
        }
        else
        {
            wait_mode(true);
        }
    }
开发者ID:foogywoo,项目名称:drone,代码行数:33,代码来源:image_filters.cpp


示例20: propose_value_instrumented

void propose_value_instrumented() {
    int i;
    int rt;
    int tot = 0;
    int min = INT_MAX;
    int max = 0;
    struct timeval t1, t2;
    
    for (i = 0; i < values_to_propose; i++) {
        generate_random_val(buffer, value_size);
        
        gettimeofday(&t1, NULL);
        proposer_submit_value(buffer, value_size);
        gettimeofday(&t2, NULL);
        rt = elapsed_time(&t1, &t2);
        if (rt < min)
            min = rt;
        if (rt > max)
            max = rt;
        tot += rt;
        
        if ((i % (values_to_propose/10)) == 0) {
            printf("Proposed %d values\n", i);
        }
    }
    
    printf("Proposed %d values\n", i);
    printf("Min: %d\n", min);
    printf("Max: %d\n", max);
    printf("Avg: %d\n", tot / values_to_propose);
}
开发者ID:tnm,项目名称:libfastpaxos,代码行数:31,代码来源:proposer_main.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ elektraFree函数代码示例发布时间:2022-05-30
下一篇:
C++ el_var函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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