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


C++ START_TIMER函数代码示例

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


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

示例1: TEST

TEST(Profiler, one_timer) {

    Profiler::initialize();
    double wait_time = clock_resolution();
    double total=0;
    { // uninitialize can not be in the same block as the START_TIMER
    START_TIMER("test_tag");
    EXPECT_EQ( 1, AC);
    total += wait(wait_time);
    END_TIMER("test_tag");

    START_TIMER("test_tag");
    EXPECT_EQ( total, ACT);
    EXPECT_EQ( 2, AC);
    total += wait(wait_time);
    total += wait(wait_time);
    END_TIMER("test_tag");

    START_TIMER("test_tag");
    EXPECT_EQ( total, ACT);
    EXPECT_EQ( 3, AC);

    }

    // test add_call
    {
        START_TIMER("add_call");
        ADD_CALLS(1000);
        EXPECT_EQ(1000, AC);
    }

    Profiler::uninitialize();

}
开发者ID:jstebel,项目名称:flow123d,代码行数:34,代码来源:profiler_test.cpp

示例2: main

int main(int argc, char *argv[]) {
	struct timeval start_time, stop_time;
	size_t i;
	int test_size = atoi(argv[1]);
	int hash_table_size = atoi(argv[2]);

	void** tmp = malloc(test_size * sizeof(void*));
	assert(tmp != NULL);

	HashTable* hash_table = hash_table_create(hash_table_size);
	printf("%d put operations .........................: ", test_size);
	fflush(stdout);
	START_TIMER(start_time);
	for (i = 0; i < test_size; ++i) {
		tmp[i] = malloc(sizeof(void));
		assert(tmp[i] != NULL);
		hash_table_insert(hash_table, (void*) tmp[i]);
	}
	STOP_TIMER(stop_time);
	printf("%.3f milisecs\n", TIME_DIFF(start_time, stop_time) / 1000);

	printf("Iterating .........................: ");
	fflush(stdout);
	START_TIMER(start_time);
	HashTableIterator* it = hash_table_iterator_create(hash_table);
	void* e = hash_table_iterator_next(it);
	while (e) {
		e = hash_table_iterator_next(it);
	}
	STOP_TIMER(stop_time);
	printf("done in %.3f milisecs\n", TIME_DIFF(start_time, stop_time) / 1000);

	return 1;
}
开发者ID:sertkaya,项目名称:elephant-reasoner,代码行数:34,代码来源:test_hash_table_performance.c

示例3: MPI_Comm_rank

void ProfilerTest::test_petsc_memory_monitor() {
    int ierr, mpi_rank;
    ierr = MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
    EXPECT_EQ( ierr, 0 );

    Profiler::initialize(); {
        PetscInt size = 10000;
        START_TIMER("A");
            Vec tmp_vector;
            VecCreateSeq(PETSC_COMM_SELF, size, &tmp_vector);
            VecDestroy(&tmp_vector);
            
            START_TIMER("C");
            END_TIMER("C");
        END_TIMER("A");
        
        START_TIMER("B");
            Vec tmp_vector1, tmp_vector2;
            VecCreateSeq(PETSC_COMM_SELF, size, &tmp_vector1);
            VecCreateSeq(PETSC_COMM_SELF, size, &tmp_vector2);
            VecDestroy(&tmp_vector1);
            VecDestroy(&tmp_vector2);
        END_TIMER("B");
    }
    PI->output(MPI_COMM_WORLD, cout);
    Profiler::uninitialize();
}
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:27,代码来源:profiler_test.cpp

示例4: ioctl_set_svc

static int ioctl_set_svc(ITF *itf,uint32_t ip,struct sockaddr_atmsvc *addr,
  const struct atm_qos *qos,int sndbuf,int flags)
{
    ENTRY *entry;

    if (flags & ATF_ARPSRV) flags |= ATF_PERM;
    if (lookup_ip(itf,ip)) return -EEXIST;
    entry = alloc_entry(1);
    entry->state = as_valid;
    entry->ip = ip;
    entry->addr = alloc_t(struct sockaddr_atmsvc);
    *entry->addr = *addr;
    entry->qos = *qos;
    entry->sndbuf = sndbuf;
    entry->flags = flags;
    if (!(flags & ATF_PERM) || (flags & ATF_ARPSRV)) {
	if (itf->arp_srv) START_TIMER(entry,CREVAL);
	else START_TIMER(entry,SREVAL);
    }
    entry->itf = itf;
    Q_INSERT_HEAD(itf->table,entry);
    if (!(flags & ATF_ARPSRV)) return 0;
    entry->state = as_invalid;
    itf->arp_srv = entry;
    (void) want_arp_srv(itf);
    return 0;
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:27,代码来源:arp.c

示例5: START_TIMER

 void ProfilerTest::test_one_timer() {
    const double TIMER_RESOLUTION = Profiler::get_resolution();
    const double DELTA = TIMER_RESOLUTION*1000;
    double total=0;
    Profiler::initialize();

    { // uninitialize can not be in the same block as the START_TIMER


    START_TIMER("test_tag");
        // test that number of calls of current timer is
        EXPECT_EQ( 1, ACC);

        // wait a TIMER_RESOLUTION time
        total += wait_sec(TIMER_RESOLUTION);
    END_TIMER("test_tag");



    START_TIMER("test_tag");
        // test that number of calls of current timer is
        EXPECT_EQ( 2, ACC);

        // test whether difference between measured time and total time is within TIMER_RESOLUTION
        EXPECT_LE( abs(ACT-total), DELTA);
        cout << "difference: " << abs(total-ACT) << ", tolerance: " << DELTA << endl;

        // wait a TIMER_RESOLUTION time
        total += wait_sec (TIMER_RESOLUTION);
        total += wait_sec (TIMER_RESOLUTION);

    END_TIMER("test_tag");

    START_TIMER("test_tag");
        EXPECT_EQ( 3, ACC);
        EXPECT_LE( abs(ACT-total), DELTA);
        cout << "difference: " << abs(total-ACT) << ", tolerance: " << DELTA << endl;
    }

    // test add_call
    {
        START_TIMER("add_call");
        ADD_CALLS(1000);
        EXPECT_EQ(1000, ACC);
    }

    // test absolute time
    {
        START_TIMER("one_second");
        wait_sec(1);
    }
    std::stringstream sout;
    PI->output(MPI_COMM_WORLD, sout);
    PI->output(MPI_COMM_WORLD, cout);

    //EXPECT_NE( sout.str().find("\"tag\": \"Whole Program\""), string::npos );

    Profiler::uninitialize();
}
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:59,代码来源:profiler_test.cpp

示例6: main

int main(int argc, char* argv[]) {
    wp_index* index;

    if(argc < 2) {
        fprintf(stderr, "Usage: %s <filename>+\n", argv[0]);
        return -1;
    }

    DIE_IF_ERROR(wp_index_create(&index, "index"));
    //wp_index_dumpinfo(index, stdout);

    printf("starting...\n");
    unsigned long total_bytes = 0;
    unsigned long chunk_bytes = 0;
    START_TIMER(total);
    START_TIMER(chunk);

    for(int i = 1; i < argc; i++) {
        FILE* f = fopen(argv[i], "r");
        if(f == NULL) {
            fprintf(stderr, "can't open %s: %s\n", argv[i], strerror(errno));
            break;
        }

        uint64_t doc_id;
        wp_entry* entry = wp_entry_new();
        DIE_IF_ERROR(wp_entry_add_file(entry, "body", f));
        DIE_IF_ERROR(wp_index_add_entry(index, entry, &doc_id));
        DIE_IF_ERROR(wp_entry_free(entry));
        fclose(f);

        struct stat fstat;
        stat(argv[i], &fstat);
        total_bytes += fstat.st_size;
        chunk_bytes += fstat.st_size;

        MARK_TIMER(chunk);
        if(TIMER_MS(chunk) > 1000) {
            MARK_TIMER(total);
#define STUFF(k, t) k / 1024, t / 1000.0, ((float)(k) / 1024.0) / ((float)(t) / 1000.0)
            fprintf(stderr, "processed %5luk in %3.1fs = %6.1fk/s. total: %5luk in %5.1fs = %6.1fk/s\n", STUFF(chunk_bytes, TIMER_MS(chunk)), STUFF(total_bytes, TIMER_MS(total)));
            RESET_TIMER(chunk);
            chunk_bytes = 0;
        }
    }
    //po = MMAP_OBJ(segment.postings, postings_list); // may have moved
    //fprintf(stderr, "after: segment has %d docs and %d postings\n", po->num_docs, po->num_postings);

    MARK_TIMER(total);
    fprintf(stderr, "In total, processed %luk in %.1fs = %.1fk/s\n", STUFF(total_bytes, TIMER_MS(total)));

    DIE_IF_ERROR(wp_index_unload(index));
    return 0;
}
开发者ID:hand-code,项目名称:whistlepig,代码行数:54,代码来源:file-indexer.c

示例7: timeout

static void timeout(ENTRY *entry)
{
    VCC *vcc,*next;

    entry->timer = NULL;
    switch (entry->state) {
	case as_resolv:
	    send_notifications(entry,0);
	    if ((entry->flags & ATF_ARPSRV) && !entry->vccs) {
		if (entry->itf) want_arp_srv(entry->itf);
		break;
	    }
	    if (!entry->vccs && !(entry->flags & (ATF_PERM | ATF_ARPSRV)))
		discard_entry(entry);
	    else entry->state = as_invalid;
	    break;
	case as_valid:
	    if (!entry->vccs && !(entry->flags & (ATF_PERM | ATF_ARPSRV)) &&
	      entry->itf->arp_srv) {
		discard_entry(entry);
		break;
	    }
	    for (vcc = entry->vccs; vcc; vcc = next) {
		next = vcc->next;
		if (!vcc->connecting)
		    if (set_ip(vcc->fd,0) < 0) {
			diag(COMPONENT,DIAG_ERROR,"set_ip(0): %s",
			  strerror(errno));
			disconnect_vcc(vcc);
		    }
	    }
	    if (entry->svc && entry->itf->arp_srv &&
	      !(entry->flags & ATF_ARPSRV)) revalidate(entry);
	    else {
		inarp_request(entry);
		START_TIMER(entry,REPLY);
		entry->state = as_invalid;
	    }
	    break;
	case as_invalid:
	    if (!entry->svc) {
		inarp_request(entry);
		START_TIMER(entry,REPLY);
	    }
	    else if ((!entry->itf || !entry->itf->arp_srv) &&
		  !(entry->flags & ATF_PERM)) discard_entry(entry);
	    break;
	default:
	    diag(COMPONENT,DIAG_FATAL,"timed out in state %s",
	      entry_state_name[entry->state]);
    }
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:52,代码来源:arp.c

示例8: EXPECT_EQ

void ProfilerTest::test_memory_propagation(){
    const int SIZE = 25;
    int allocated_whole = 0;
    int allocated_A = 0;
    int allocated_B = 0;
    int allocated_C = 0;
    int allocated_D = 0;
    
    Profiler::initialize();
    {
        allocated_whole = MALLOC;
        allocated_whole += alloc_and_dealloc<int>(SIZE);
        EXPECT_EQ(MALLOC, allocated_whole);
        
        START_TIMER("A");
            allocated_A += alloc_and_dealloc<int>(10 * SIZE);
            EXPECT_EQ(MALLOC, allocated_A);
            
            START_TIMER("B");
                allocated_B += alloc_and_dealloc<int>(100 * SIZE);
                
                START_TIMER("C");
                    EXPECT_EQ(MALLOC, allocated_C);
                END_TIMER("C");
                allocated_B += allocated_C;
                
            END_TIMER("B");
            allocated_A += allocated_B;
            
            allocated_A += alloc_and_dealloc<int>(10 * SIZE);
            
            for(int i = 0; i < 5; i++) {
                START_TIMER("D");
                    allocated_D += alloc_and_dealloc<int>(1 * SIZE);
                END_TIMER("D");
                START_TIMER("D");
                    allocated_D += alloc_and_dealloc<int>(1 * SIZE);
                END_TIMER("D");
            }
            allocated_A += allocated_D;
            
            
        END_TIMER("A");
        allocated_whole += allocated_A;
    }
    PI->propagate_timers();
    EXPECT_EQ(MALLOC, allocated_whole);
    EXPECT_EQ(MALLOC, DEALOC);
    Profiler::uninitialize();
}
开发者ID:jbrezmorf,项目名称:flow123d,代码行数:50,代码来源:profiler_test.cpp

示例9: myContext

bool
RenderArea::on_expose_event (GdkEventExpose *event) {
    try {
        /*GdkGLDrawable *gldrawable =*/ gtk_widget_get_gl_drawable (GTK_WIDGET(gobj()));
        ScopedGLContext myContext(this);

        if (_myRenderer && _myScene) {
            if (_isFirstFrame) {
                _myRenderer->getCurrentScene()->updateAllModified();
                _isFirstFrame = false;
            }

            STOP_TIMER(frames);
            asl::getDashboard().cycle();
            START_TIMER(frames);

            onFrame();

            //START_TIMER(dispatchEvents);
            //y60::EventDispatcher::get().dispatch();
            //STOP_TIMER(dispatchEvents);

            START_TIMER(handleRequests);
            _myRequestManager.handleRequests();
            STOP_TIMER(handleRequests);

            renderFrame();
            swapBuffers();

            /** done rendering **/
        } else {
            // nothing to render... just clear the buffer to avoid pixel garbage
            glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
            swapBuffers();
        }

        if (_myJSContext) {
            MAKE_SCOPE_TIMER(gc);
            JS_GC(_myJSContext);
        }
    } catch (const asl::Exception & ex) {
        AC_FATAL << "Exception caught: " << ex;
    } catch (const exception & ex) {
        AC_FATAL << "Exception caught: " << ex.what();
    } catch (...) {
        AC_FATAL << "Unknown exception";
    }
    return true;
}
开发者ID:modemuser,项目名称:y60,代码行数:49,代码来源:RenderArea.cpp

示例10: revalidate

static void revalidate(ENTRY *entry)
{
    entry->state = as_resolv;
    if (want_arp_srv(entry->itf) <= 0) return;
    arp_request(entry->itf,entry->ip);
    START_TIMER(entry,REPLY);
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:7,代码来源:arp.c

示例11: rbch_timeout

/*---------------------------------------------------------------------------*
 *	watchdog routine
 *---------------------------------------------------------------------------*/
static void
rbch_timeout(struct rbch_softc *sc)
{
	bchan_statistics_t bs;

	/* get # of bytes in and out from the HSCX driver */

	(*sc->sc_ilt->bchannel_driver->bch_stat)
		(sc->sc_ilt->l1token, sc->sc_ilt->channel, &bs);

	sc->sc_ioutb += bs.outbytes;
	sc->sc_iinb += bs.inbytes;

	if((sc->sc_iinb != sc->sc_linb) || (sc->sc_ioutb != sc->sc_loutb) || sc->sc_fn)
	{
		int ri = (sc->sc_iinb - sc->sc_linb)/I4BRBCHACCTINTVL;
		int ro = (sc->sc_ioutb - sc->sc_loutb)/I4BRBCHACCTINTVL;

		if((sc->sc_iinb == sc->sc_linb) && (sc->sc_ioutb == sc->sc_loutb))
			sc->sc_fn = 0;
		else
			sc->sc_fn = 1;

		sc->sc_linb = sc->sc_iinb;
		sc->sc_loutb = sc->sc_ioutb;

		if (sc->sc_cd)
			i4b_l4_accounting(sc->sc_cd->cdid, ACCT_DURING,
			    sc->sc_ioutb, sc->sc_iinb, ro, ri, sc->sc_ioutb, sc->sc_iinb);
 	}
	START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:35,代码来源:i4b_rbch.c

示例12: ioctl_set_pvc

static int ioctl_set_pvc(ITF *itf,uint32_t ip,struct sockaddr_atmpvc *addr,
  const struct atm_qos *qos,int sndbuf,int flags)
{
    ENTRY *entry;
    VCC *vcc;
    int fd,result;

    if (lookup_ip(itf,ip)) return -EEXIST; 
    if ((fd = connect_vcc((struct sockaddr *) addr,qos,sndbuf,0)) < 0)
	return fd;
    if ((result = set_ip(fd,ip)) < 0) {
	do_close(fd);
	return result;
    }
    if (flags & ATF_NULL) {
	if ((result = set_encap(fd,0)) < 0) return result;
	flags |= ATF_PERM;
    }
    entry = alloc_entry(0);
    entry->state = as_valid;
    entry->ip = ip;
    entry->qos = *qos;
    entry->sndbuf = sndbuf;
    entry->flags = flags;
    entry->itf = itf;
    vcc = alloc_t(VCC);
    vcc->active = 1;
    vcc->connecting = 0;
    vcc->fd = fd;
    vcc->entry = entry;
    if (!(flags & ATF_PERM)) START_TIMER(entry,CREVAL);
    Q_INSERT_HEAD(entry->vccs,vcc);
    Q_INSERT_HEAD(itf->table,entry);
    return 0;
}
开发者ID:FelipeFernandes1988,项目名称:Alice-1121-Modem,代码行数:35,代码来源:arp.c

示例13: parseInternalPostgres

static Node *
parseInternalPostgres (void) //TODO make copyObject work first
{
    Node *result;
    START_TIMER("module - parser");

    NEW_AND_ACQUIRE_MEMCONTEXT("PARSER_CONTEXT");

    // parse
    int rc = postgresparse();
    if (rc)
    {
        ERROR_LOG("parse error!");
        return NULL;
    }

    STOP_TIMER("module - parser");

    DEBUG_LOG("query block model generated by parser is:\n%s\n\n%s",
            nodeToString(postgresParseResult),
            beatify(nodeToString(postgresParseResult)));

    // create copy of parse result in parent context
    FREE_MEM_CONTEXT_AND_RETURN_COPY(Node,postgresParseResult);
}
开发者ID:dayu070,项目名称:GProm,代码行数:25,代码来源:parser_postgres.c

示例14: rbch_connect

/*---------------------------------------------------------------------------*
 *	this routine is called from L4 handler at connect time
 *---------------------------------------------------------------------------*/
static void
rbch_connect(void *softc, void *cdp)
{
	call_desc_t *cd = (call_desc_t *)cdp;
	struct rbch_softc *sc = softc;

	sc->sc_bprot = cd->bprot;

#if I4BRBCHACCT
	if(sc->sc_bprot == BPROT_RHDLC)
	{
		sc->sc_iinb = 0;
		sc->sc_ioutb = 0;
		sc->sc_linb = 0;
		sc->sc_loutb = 0;

		START_TIMER(sc->sc_callout, rbch_timeout, sc, I4BRBCHACCTINTVL*hz);
	}
#endif
	if(!(sc->sc_devstate & ST_CONNECTED))
	{
		NDBGL4(L4_RBCHDBG, "B channel %d at ISDN %d, wakeup",
			cd->channelid, cd->isdnif);
		sc->sc_devstate |= ST_CONNECTED;
		sc->sc_cd = cdp;
		wakeup((void *)sc);
		selnotify(&sc->selp, 0, 0);
	}
}
开发者ID:RyanLucchese,项目名称:rumpkernel-netbsd-src,代码行数:32,代码来源:i4b_rbch.c

示例15: xcb_check_cb

/*
 * Instead of polling the X connection socket we leave this to
 * xcb_poll_for_event() which knows better than we can ever know.
 *
 */
static void xcb_check_cb(EV_P_ ev_check *w, int revents) {
    xcb_generic_event_t *event;

    while ((event = xcb_poll_for_event(conn)) != NULL) {
        if (event->response_type == 0) {
            xcb_generic_error_t *error = (xcb_generic_error_t*)event;
            if (debug_mode)
                fprintf(stderr, "X11 Error received! sequence 0x%x, error_code = %d\n",
                        error->sequence, error->error_code);
            free(event);
            continue;
        }

        /* Strip off the highest bit (set if the event is generated) */
        int type = (event->response_type & 0x7F);

        switch (type) {
            case XCB_KEY_PRESS:
                handle_key_press((xcb_key_press_event_t*)event);
                break;

            case XCB_KEY_RELEASE:
                /* If this was the backspace or escape key we are back at an
                 * empty input, so turn off the screen if DPMS is enabled, but
                 * only do that after some timeout: maybe user mistyped and
                 * will type again right away */
                START_TIMER(dpms_timeout, TSTAMP_N_SECS(inactivity_timeout),
                            turn_off_monitors_cb);
                break;

            case XCB_VISIBILITY_NOTIFY:
                handle_visibility_notify(conn, (xcb_visibility_notify_event_t*)event);
                break;

            case XCB_MAP_NOTIFY:
                if (!dont_fork) {
                    /* After the first MapNotify, we never fork again. We don’t
                     * expect to get another MapNotify, but better be sure… */
                    dont_fork = true;

                    /* In the parent process, we exit */
                    if (fork() != 0)
                        exit(0);

                    ev_loop_fork(EV_DEFAULT);
                }
                break;

            case XCB_CONFIGURE_NOTIFY:
                handle_screen_resize();
                break;

            default:
                if (type == xkb_base_event)
                    process_xkb_event(event);
        }

        free(event);
    }
}
开发者ID:Kamori,项目名称:i3lock,代码行数:65,代码来源:i3lock.c


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