コード例 #1
0
ファイル: profiler_test.cpp プロジェクト: jstebel/flow123d
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();

}
コード例 #2
0
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;
}
コード例 #3
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
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();
}
コード例 #4
0
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;
}
コード例 #5
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
 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();
}
コード例 #6
0
ファイル: file-indexer.c プロジェクト: hand-code/whistlepig
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;
}
コード例 #7
0
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]);
    }
}
コード例 #8
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
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();
}
コード例 #9
0
ファイル: RenderArea.cpp プロジェクト: modemuser/y60
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;
}
コード例 #10
0
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);
}
コード例 #11
0
/*---------------------------------------------------------------------------*
 *	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);
}
コード例 #12
0
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;
}
コード例 #13
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
void ProfilerTest::test_absolute_time() {
    Profiler::initialize();

    // 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);
    
    // try to transform profiler data using python
    PI->output(MPI_COMM_WORLD);
    PI->transform_profiler_data (".txt", "SimpleTableFormatter");
    
    int ierr, mpi_rank;
    ierr = MPI_Comm_rank(MPI_COMM_WORLD, &mpi_rank);
    EXPECT_EQ( ierr, 0 );
    
    // 0 processor will have valid profiler report
    // other processors should have empty string only
    if (mpi_rank == 0) {
        // test timer resolution, requiring atleast 2 digit places
        EXPECT_NE( sout.str().find("cumul-time-min\": \"1.00"), string::npos );
        EXPECT_NE( sout.str().find("cumul-time-max\": \"1.00"), string::npos );
    } else {
        EXPECT_TRUE( sout.str().empty() );
    }
    
    

    Profiler::uninitialize();
}
コード例 #14
0
ファイル: parser_postgres.c プロジェクト: dayu070/GProm
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);
}
コード例 #15
0
/*---------------------------------------------------------------------------*
 *	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);
	}
}
コード例 #16
0
ファイル: i3lock.c プロジェクト: Kamori/i3lock
/*
 * 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);
    }
}
コード例 #17
0
ファイル: test_rewriter.c プロジェクト: dayu070/GProm
int
main (int argc, char* argv[])
{
    char *result;

    READ_OPTIONS_AND_INIT("testrewriter", "Run all stages on input and output rewritten SQL.");

    START_TIMER("TOTAL");

    // read from terminal
    if (getStringOption("input.sql") == NULL)
    {
        result = rewriteQueryFromStream(stdin);
        ERROR_LOG("REWRITE RESULT FROM STREAM IS <%s>", result);
    }
    // parse input string
    else
    {
        result = rewriteQuery(getStringOption("input.sql"));
        ERROR_LOG("REWRITE RESULT FROM STRING IS:\n%s", result);
    }

    // call executor
    execute(result);

    STOP_TIMER("TOTAL");
    OUT_TIMERS();

    shutdownApplication();
//    freeOptions();
//    destroyMemManager();

    return EXIT_SUCCESS;
}
コード例 #18
0
ファイル: cfd.cpp プロジェクト: Ethan999/OpenDwarfs
void upload(cl_command_queue commands, cl_mem dst, T* src, int N)
{
	int err = clEnqueueWriteBuffer(commands, dst, CL_TRUE, 0, sizeof(T) * N, src, 0, NULL, &ocdTempEvent);
	clFinish(commands);
	START_TIMER(ocdTempEvent, OCD_TIMER_H2D, "CFD Data Copy", ocdTempTimer)
	END_TIMER(ocdTempTimer)
	CHKERR(err, "Unable to write memory to device");
}
コード例 #19
0
ファイル: adios_posix.c プロジェクト: acbauer/ADIOS
enum ADIOS_FLAG adios_posix_should_buffer (struct adios_file_struct * fd
                                          ,struct adios_method_struct * method
                                          )
{
    struct adios_POSIX_data_struct * p = (struct adios_POSIX_data_struct *)
                                                          method->method_data;

    START_TIMER (ADIOS_TIMER_POSIX_AD_SHOULD_BUFFER);

    if (fd->shared_buffer == adios_flag_no && fd->mode != adios_mode_read)
    {
        // write the process group header
        adios_write_process_group_header_v1 (fd, fd->write_size_bytes);

        lseek (p->b.f, fd->base_offset, SEEK_SET);
        START_TIMER (ADIOS_TIMER_POSIX_MD);
        ssize_t s = write (p->b.f, fd->buffer, fd->bytes_written);
        STOP_TIMER (ADIOS_TIMER_POSIX_MD);
        if (s != fd->bytes_written)
        {
            fprintf (stderr, "POSIX method tried to write %llu, "
                             "only wrote %lld\n"
                    ,fd->bytes_written
                    ,(int64_t)s
                    );
        }
        fd->base_offset += s;
        fd->offset = 0;
        fd->bytes_written = 0;
        adios_shared_buffer_free (&p->b);

        // setup for writing vars
        adios_write_open_vars_v1 (fd);
        p->vars_start = lseek (p->b.f, fd->offset, SEEK_CUR);  // save loc
        p->vars_header_size = p->vars_start - fd->base_offset;  // the size
        p->vars_start -= fd->offset; // adjust to start of header
        fd->base_offset += fd->offset;  // add the size of the vars header
        fd->offset = 0;
        fd->bytes_written = 0;
        adios_shared_buffer_free (&p->b);
    }

    STOP_TIMER (ADIOS_TIMER_POSIX_AD_SHOULD_BUFFER);

    return fd->shared_buffer;   // buffer if there is space
}
コード例 #20
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
// testing non-fatal functioning of Profiler when debug is off
TEST(Profiler, test_calls_only) {
    Profiler::initialize();
    START_TIMER("sub1");
    END_TIMER("sub1");
    PI->output(MPI_COMM_WORLD, cout);
    Profiler::uninitialize();

}
コード例 #21
0
ファイル: isic_l1fsm.c プロジェクト: Tommmster/netbsd-avr32
/*---------------------------------------------------------------------------*
 *	Timer T4 start
 *---------------------------------------------------------------------------*/
static void
T4_start(struct isic_softc *sc)
{
	NDBGL1(L1_T_MSG, "state = %s", isic_printstate(sc));
	sc->sc_I430T4 = 1;

	START_TIMER(sc->sc_T4_callout, timer4_expired, sc, hz);
}
コード例 #22
0
ファイル: cfd.cpp プロジェクト: Ethan999/OpenDwarfs
void download(cl_command_queue commands, T* dst, cl_mem src, int N)
{
	int err = clEnqueueReadBuffer(commands, src, CL_TRUE, 0, sizeof(T)*N, dst, 0, NULL, &ocdTempEvent);
	clFinish(commands);
	START_TIMER(ocdTempEvent, OCD_TIMER_D2H, "CFD Data Copy", ocdTempTimer)
	END_TIMER(ocdTempTimer)
	CHKERR(err, "Unable to read memory from device");
}
コード例 #23
0
/**
  * The parser uses a code sandwich to wrap the parsing process. Before
  * the process begins, WillBuildModel() is called. Afterwards the parser
  * calls DidBuildModel().
  * @update rickg 03.20.2000
  * @param  aParserContext
  * @param  aSink
  * @return error code (almost always 0)
  */
NS_IMETHODIMP
CViewSourceHTML::WillBuildModel(const CParserContext& aParserContext,
                                nsITokenizer* aTokenizer,
                                nsIContentSink* aSink)
{
  nsresult result=NS_OK;

#ifdef RAPTOR_PERF_METRICS
  vsTimer.Reset();
  NS_START_STOPWATCH(vsTimer);
#endif

  STOP_TIMER();
  mSink=(nsIHTMLContentSink*)aSink;

  if((!aParserContext.mPrevContext) && (mSink)) {

    nsAString & contextFilename = aParserContext.mScanner->GetFilename();
    mFilename = Substring(contextFilename,
                          12, // The length of "view-source:"
                          contextFilename.Length() - 12);

    mDocType=aParserContext.mDocType;
    mMimeType=aParserContext.mMimeType;
    mDTDMode=aParserContext.mDTDMode;
    mParserCommand=aParserContext.mParserCommand;
    mTokenizer = aTokenizer;

#ifdef DUMP_TO_FILE
    if (gDumpFile) {

      fprintf(gDumpFile, "<html>\n");
      fprintf(gDumpFile, "<head>\n");
      fprintf(gDumpFile, "<title>");
      fprintf(gDumpFile, "Source of: ");
      fputs(NS_ConvertUTF16toUTF8(mFilename).get(), gDumpFile);
      fprintf(gDumpFile, "</title>\n");
      fprintf(gDumpFile, "<link rel=\"stylesheet\" type=\"text/css\" href=\"resource://gre/res/viewsource.css\">\n");
      fprintf(gDumpFile, "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\">\n");
      fprintf(gDumpFile, "</head>\n");
      fprintf(gDumpFile, "<body id=\"viewsource\">\n");
      fprintf(gDumpFile, "<pre id=\"line1\">\n");
    }
#endif //DUMP_TO_FILE
  }


  if(eViewSource!=aParserContext.mParserCommand)
    mDocType=ePlainText;
  else mDocType=aParserContext.mDocType;

  mLineNumber = 1;

  START_TIMER();

  return result;
}
コード例 #24
0
ファイル: make-queries.c プロジェクト: hand-code/whistlepig
int main(int argc, char* argv[]) {
  if(argc < 2) {
    fprintf(stderr, "Usage: %s <filename>+\n", argv[0]);
    return -1;
  }

  fprintf(stderr, "starting...\n");

  new_query = 1;

  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;
    }
    parse_file(f);
    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;
    }
  }

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

  return 0;
}
コード例 #25
0
ファイル: prov_rewriter_main.c プロジェクト: dayu070/GProm
QueryOperator *
rewriteProvenanceComputation (ProvenanceComputation *op)
{
    // for a sequence of updates of a transaction merge the sequence into a single
    // query before rewrite.
    if (op->inputType == PROV_INPUT_UPDATE_SEQUENCE
            || op->inputType == PROV_INPUT_TRANSACTION)
    {
        START_TIMER("rewrite - merge update reenactments");
        mergeUpdateSequence(op);
        STOP_TIMER("rewrite - merge update reenactments");

        // need to restrict to updated rows?
        if (op->inputType == PROV_INPUT_TRANSACTION
                && HAS_STRING_PROP(op,PROP_PC_ONLY_UPDATED))
        {
            START_TIMER("rewrite - restrict to updated rows");
            restrictToUpdatedRows(op);
            STOP_TIMER("rewrite - restrict to updated rows");
        }
    }

    if (isRewriteOptionActivated(OPTION_TREEIFY_OPERATOR_MODEL))
    {
        treeify((QueryOperator *) op);
        INFO_LOG("treeifyed operator model:\n\n%s", operatorToOverviewString((Node *) op));
        DEBUG_LOG("treeifyed operator model:\n\n%s", beatify(nodeToString(op)));
        ASSERT(isTree((QueryOperator *) op));
    }

    switch(op->provType)
    {
        case PROV_PI_CS:
            if (isRewriteOptionActivated(OPTION_PI_CS_USE_COMPOSABLE))
                return rewritePI_CSComposable(op);
            else
                return rewritePI_CS(op);
        case PROV_TRANSFORMATION:
            return rewriteTransformationProvenance((QueryOperator *) op);
    }
    return NULL;
}
コード例 #26
0
ファイル: profiler_test.cpp プロジェクト: jbrezmorf/flow123d
void ProfilerTest::test_memory_profiler() {
    const int ARR_SIZE = 1000;
    const int LOOP_CNT = 1000;
    Profiler::initialize();

    {
        START_TIMER("memory-profiler-int");
        // alloc and dealloc array of int
        for (int i = 0; i < LOOP_CNT; i++) alloc_and_dealloc<int>(ARR_SIZE);
        // test that we deallocated all allocated space
        EXPECT_EQ(MALLOC, DEALOC);
        // test that allocated space is correct size
        EXPECT_EQ(MALLOC, ARR_SIZE * LOOP_CNT * sizeof(int));
        END_TIMER("memory-profiler-int");


        START_TIMER("memory-profiler-double");
        // alloc and dealloc array of float
        for (int i = 0; i < LOOP_CNT; i++) alloc_and_dealloc<double>(ARR_SIZE);
        // test that we deallocated all allocated space
        EXPECT_EQ(MALLOC, DEALOC);
        // test that allocated space is correct size
        EXPECT_EQ(MALLOC, ARR_SIZE * LOOP_CNT * sizeof(double));
        END_TIMER("memory-profiler-double");


        START_TIMER("memory-profiler-simple");
        // alloc and dealloc array of float
        for (int i = 0; i < LOOP_CNT; i++) {
            int * j = new int;
            delete j;
        }
        // test that we deallocated all allocated space
        EXPECT_EQ(MALLOC, DEALOC);
        // test that allocated space is correct size
        EXPECT_EQ(MALLOC, LOOP_CNT * sizeof(int));
        END_TIMER("memory-profiler-simple");
    }

    PI->output(MPI_COMM_WORLD, cout);
    Profiler::uninitialize();
}
コード例 #27
0
ファイル: timeout.c プロジェクト: Claruarius/stblinux-2.6.37
void on_T308_1(void *user) /* WAIT_REL or REL_REQ */
{
    SOCKET *sock = user;

    diag(COMPONENT,DIAG_DEBUG,"T308_1 on %s",kptr_print(&sock->id));
    if (sock->state != ss_wait_rel && sock->state != ss_rel_req)
        complain(sock,"T308_1");
    send_release(sock,ATM_CV_TIMER_EXP,308); /* @@@ ? */
    sock->conn_timer = NULL;
    START_TIMER(sock,T308_2);
}
コード例 #28
0
ファイル: timeout.c プロジェクト: Claruarius/stblinux-2.6.37
void on_T313(void *user) /* ACCEPTING */
{
    SOCKET *sock = user;

    diag(COMPONENT,DIAG_DEBUG,"T313 on %s",kptr_print(&sock->id));
    if (sock->state != ss_accepting) complain(sock,"T313");
    send_release(sock,ATM_CV_TIMER_EXP,313);
    sock->conn_timer = NULL;
    START_TIMER(sock,T308_1);
    new_state(sock,ss_rel_req);
}
コード例 #29
0
ファイル: i4b_l3timer.c プロジェクト: MarginC/kame
/*---------------------------------------------------------------------------*
 *	timer T303 start
 *---------------------------------------------------------------------------*/
void
T303_start(call_desc_t *cd)
{
	if (cd->T303 == TIMER_ACTIVE)
		return;
		
	NDBGL3(L3_T_MSG, "cr = %d", cd->cr);
	cd->T303 = TIMER_ACTIVE;

	START_TIMER(cd->T303_callout, T303_timeout, cd, T303VAL);
}
コード例 #30
0
ファイル: timeout.c プロジェクト: Claruarius/stblinux-2.6.37
void on_T360(void *user)
{
    SOCKET *sock = user;

    diag(COMPONENT,DIAG_DEBUG,"T360 on %s",kptr_print(&sock->id));
    if (sock->state != ss_mod_req) complain(sock,"T360");
    send_release(sock,ATM_CV_TIMER_EXP,360);
    sock->conn_timer = NULL;
    START_TIMER(sock,T308_1);
    new_state(sock,ss_rel_req);
}