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

C++ clock函数代码示例

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

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



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

示例1: jiveL_thread_time

int jiveL_thread_time(lua_State *L) {
	lua_pushinteger(L, (int)(clock() * 1000 / CLOCKS_PER_SEC));
	return 1;
}
开发者ID:presslab-us,项目名称:jivelite,代码行数:4,代码来源:jive_framework.c


示例2: osc_gen

void osc_gen(int argc, char *argv[])
{
	//This function serves as an Osccilator bank (an arrary of oscillators) for additive synthesis
	//It produces more natural sounding waves confined in the spectrum of the availabke ranges of the sampling rate at or above the Nyquist limit
	
	//Structurally, this program is very similar to sig_gen, except that we will only be calling upon sine_wave_node and implement additive synthesis
	//to achieve the other waveforms. If osc_gen_num_oscs == 1 (meaning only 1 oscillator) a normal sine wave will be produced.
	
	//This function makes use of wave_generator.c/.h objects and functions
	
	/***************USAGE***************
     oscgen outfile dur srate num_chans, amp, freq, wavetype, num_oscs
     **********************************/
    if(argc < OSC_GEN_NARGS)
    {
        fprintf(stderr, "insufficient arguments.\n"
				"usage: oscgen outfile dur srate num_chans amp freq wavetype   num_oscs\n"
				"where wavetype =:\n"
				"			0 = square\n"
				"			1 = triangle\n"
				"			2 = sawtooth up\n"
				"			3 = sawtooth down\n"
				"			4 = pulse\n"
				"dur		= duration of outfile (seconds)\n"
				"srate		= required sample rate of outfile\n"
				"amp		= amplitude value or breakpoint file (0 < amp <= 1.0)\n"
				"freq		= frequency value (freq > 0) or breakpoint file.\n"
				"num_oscs	= number of oscillators (where 1 is normal sine wave)\n"
				);
        exit(1);
    }
	
	/********* initialize all dynamic resources to default states **********/
	PSF_PROPS outprops;
	int ofd = -1;
	int error = 0;
	PSF_CHPEAK* peaks = NULL;	
	psf_format outformat =  PSF_FMT_UNKNOWN;
	long nframes = NFRAMES;
	float* outframe = NULL;
	double amp,freq,dur;
	long outframes,nbufs = 0,num_oscs,i; //num_oscs holds number of oscillators for additive synthesis
	long remainder;
	int samptype = PSF_SAMP_16;
	OSCIL** oscs = NULL; //an array of oscil pointers (because additive synthesis requires more than one oscillators)
	double* oscamps = NULL; //for oscillator bank amplitudes and frequencies
	double* oscfreqs = NULL;
	double phase = 0.0;
	double ampfac,freqfac,ampadjust; //Because we cannot know the number of oscillators before hand, we need to calculate it cumulatively
	//Recall that adding sine waves amplitude is as simple as numerically adding the amplitude values. So 1 + 3 + 5 + 7 will yield an amp
	//value of 16. However, we want amp to be between -1 and 1 --> therefore total amp is 1/(1^2) + 1/(3^2) + 1/(5^2) + 1/(7^2) = 1 + 1/9 + 1/25 + 1/49 = 1.172
	//General Rule : totalamp = Sum (from n = 0 to N) 1/(2n-1)^2 where N = number of oscillators
	
	FILE* fpfreq = NULL;
	BRKSTREAM *freqstream = NULL, *ampstream = NULL;
	unsigned long brkfreqSize = 0;
	double minval = 0.0,maxval= 0.0;
	FILE* fpamp = NULL;
	unsigned long brkampSize = 0;
	double amp_minval = 0.0,amp_maxval= 0.0;
	clock_t starttime, endtime;
	int wavetype;
	oscs = NULL;
	
	
	/********** error checking on wave type **********/
    wavetype = atoi(argv[OSC_GEN_WAVETYPE]);
    if(wavetype < OSC_GEN_SQUARE || wavetype > OSC_GEN_PULSE)
    {
        fprintf(stderr, "Error: wavetype not defined\n");
        goto exit;
    }
	
	/********** error checking on number of oscillators **********/
	num_oscs = atoi(argv[OSC_GEN_NUM_OSCS]);
	if(num_oscs <= 0)
	{
		fprintf(stderr, "Error: number of oscillators must be positive\n");
		goto exit;
	}
	
	/********** define outfile format (with embedded error checking) **********/
	outprops.srate = atoi(argv[OSC_GEN_SRATE]);
	if(outprops.srate <= 0)
	{
		fprintf(stderr, "Error: srate must be positive\n");
		goto exit;
	}
	outprops.chans = atoi(argv[OSC_GEN_NUM_CHANS]);
	if(outprops.chans <= 0)
	{
		fprintf(stderr, "Error: number of channels must be positive\n");
		goto exit;
	}
	outprops.samptype = (psf_stype) samptype;
	outprops.chformat = STDWAVE;
	
	dur = atof(argv[OSC_GEN_DUR]);
    if(dur <= 0.0)
    {
//.........这里部分代码省略.........
开发者ID:RohanJ,项目名称:PersonalTesting,代码行数:101,代码来源:CTest.c


示例3:

void okim6295_device::device_clock_changed()
{
	int divisor = m_pin7_state ? 132 : 165;
	m_stream->set_sample_rate(clock() / divisor);
}
开发者ID:broftkd,项目名称:mess-svn,代码行数:5,代码来源:okim6295.c


示例4: calculate_rates

void ym2203_device::device_clock_changed()
{
	calculate_rates();
	ym2203_clock_changed(m_chip, clock(), clock() / 72);
}
开发者ID:Robbbert,项目名称:store1,代码行数:5,代码来源:2203intf.cpp


示例5: clock

void rectangle::begin()
{
	m_start = clock();
}
开发者ID:shuaihuzhou,项目名称:openglExample,代码行数:4,代码来源:ShZrectangle.cpp


示例6: main

 int main(int ac, char *argv[]) {

	if (ac<2) {
		printf("\n  This demo will show how a Sparse Distributed Memory\n");
		printf("  works. The implementation uses the advanced implementation \n");
		printf("  with different distributions.\n");
		printf("  The distributions are relativ and absolute, with linear\n");
		printf("  and gaussian functions (argument's are (1) linear,\n");
		printf("  (2) gaussian and (3) with NAND ditance masurement. After the\n");
		printf("  initialization phase rarely used entries are deleted.\n");
		printf("\n   syntax:");
		printf("\n     %s <df> <a/r> <al> <dl> <mems> <inits> <tests> <thrs> <rem>", argv[0]);
		printf("\n");
		printf("\n    <df> specifies the distribution function:");
		printf("\n		0=linear with Hamming distance,");
		printf("\n		1=gaussian with Hamming distance,");
		printf("\n		2=with NAND distance masurement.");   
		printf("\n    <a/r> absolute(0) or relativ(1) distance masurement.");
		printf("\n    <al> stands for the adress length.");
		printf("\n    <dl> stands for the data length.");
		printf("\n    <mems> specifies the number of address data vector tupels.");
		printf("\n    <inits> indicates the number of initialization vectors");
		printf("\n    <tests> indicates the number of vectors stored in the memory");
		printf("\n    <thres> specifies the threshold value indicates the percentage");
		printf("\n            that the influence goes down with each distance step.");
		printf("\n    <rem> indicates the minimum influence the initialization phase");
		printf("\n          must have had on each memory vector, so it doesn't gets deleted.\n"); 
		printf("\n    try for instance '%s 0 0 40 50 5000 500 6000 0.085 0.0',", argv[0]);
		printf("\n              or try '%s 1 0 40 50 2000 400 2400 0.075 0.0',", argv[0]);
		printf("\n              or try '%s 1 1 40 50 2000 500 2400 0.075 0.0',", argv[0]);
		printf("\n              or try '%s 2 1 40 50 2000 500 2400 0.07 0.0',", argv[0]);
		printf("\n              or try '%s 2 0 40 50 2000 500 2400 0.08 0.0'.", argv[0]);
		printf("\n\n");
		exit(0);
	}
	
	vei_t ADDR_LEN=atoi(argv[3]);
	vei_t DATA_LEN=atoi(argv[4]);
	vei_t MEM_SIZE=atoi(argv[5]);
	vei_t INIT_SIZE=atoi(argv[6]);
	vei_t TEST_SIZE=atoi(argv[7]);
	oas_t THRS=atof(argv[8]);
	oas_t REM=atof(argv[9]);
	ve_t AbsRel=atoi(argv[2]);
	ve_t fct=atoi(argv[1]);
	
	SDMAfct sdma(MEM_SIZE, ADDR_LEN, DATA_LEN);
	sdma.create(MEM_SIZE, ADDR_LEN, DATA_LEN, THRS);
	BinVector v1, v2, b1, b2; 
	KVector hd(MEM_SIZE); // keep all values in the vector
	vei_t d=0;
	
	v1.create(ADDR_LEN);  v2.create(ADDR_LEN);
	b1.create(DATA_LEN);  b2.create(DATA_LEN);
	for (vei_t i=0;i<ADDR_LEN;i++) { v1.set_comp(0,i);  v2.set_comp(0,i); }   
	for (vei_t i=0;i<DATA_LEN;i++) { b1.set_comp(0,i);  b2.set_comp(0,i); }
	v1.set_comp(1,2); v1.set_comp(1,11);  v1.set_comp(1,12); v1.tgl_comp(13); 
	v1.tgl_comp(23); v1.tgl_comp(27);   
	b1.set_comp(1,2); b1.set_comp(1,12); b1.set_comp(1,22); b1.set_comp(1,17);
	
	printf(" Creating %i random vectors as the address space.\n\r", MEM_SIZE);  
	sdma.random_init();  
	
	printf(" Adding %i (random) vectors i for initialization  tempsum = new BVector<oas_t>;n random places.\n\r", INIT_SIZE); 
	int tm;
	tm = clock();
	for (vei_t k=0; k<INIT_SIZE; k++) 
	{  
     		for (vei_t i=0;i<ADDR_LEN;i++) 
           		 v2.set_comp(floor(2.0*rand()/(RAND_MAX+1.0)),i); 
		switch (fct)
		{
			case 0: d = sdma.store(v2, b2, AbsRel); break;
			case 1: d = sdma.store_gauss(v2, b2, AbsRel, DENS_INIT); break;
			case 2: d = sdma.store_nand(v2, b2, AbsRel); break;
		}
		if (k<10) 
		{
			printf(" %i: ",d);
			for (vei_t i=0;i<v2.get_dim();i++) 
			printf("%i",v2.get_comp(i));
			printf("  ");
			printv(&b2);
		} else printf(".");     
  	}
	tm = clock() - tm;
	printf("time during calculation: %i", tm);   
	printf("\n\r");
	
	printf("remove all empty addresses, address space is now %i entries large.", sdma.remove(REM));   
	printf("\n\r");
	
	printf(" Storing v1's data vector, which is:\n\r");
	printv(&b1);
	//sdma.store(v1, b1, AbsRel);
	switch (fct)
	{
		case 0: sdma.store(v1, b1, AbsRel); d = sdma.store(v1, b1, AbsRel); break;
		case 1: sdma.store_gauss(v1, b1, AbsRel, DENS_INIT); d = sdma.store_gauss(v1, b1, AbsRel, DENS); break;
		case 2: sdma.store_nand(v1, b1, AbsRel); d = sdma.store_nand(v1, b1, AbsRel); break;
//.........这里部分代码省略.........
开发者ID:Fabianx,项目名称:cstk,代码行数:101,代码来源:sdma_t.cpp


示例7: main

////////////////////////////////////////////////////////////////////////////////
// Program main
////////////////////////////////////////////////////////////////////////////////
int
main( int argc, char** argv) {
    int num_clusters;
    
    // For profiling 
    clock_t seed_start, seed_end, seed_total = 0;
    clock_t regroup_start, regroup_end, regroup_total = 0;
    int regroup_iterations = 0;
    clock_t params_start, params_end, params_total = 0;
    int params_iterations = 0;
    clock_t constants_start, constants_end, constants_total = 0;
    int constants_iterations = 0;
    clock_t total_timer = clock();
    double total_time = 0;
    clock_t io_timer;
    double io_time = 0;
    clock_t cpu_timer;
    double cpu_time = 0;

    io_timer = clock();
    // Validate the command-line arguments, parse # of clusters, etc 
    if(validateArguments(argc,argv,&num_clusters)) {
        return 1; //Bard args
    }
    
    int num_dimensions;
    int num_events;
    
    // Read FCS data   
    PRINT("Parsing input file...");
    // This stores the data in a 1-D array with consecutive values being the dimensions from a single event
    // (num_events by num_dimensions matrix)
    float* fcs_data_by_event = readData(argv[2],&num_dimensions,&num_events);    

    if(!fcs_data_by_event) {
        printf("Error parsing input file. This could be due to an empty file ");
        printf("or an inconsistent number of dimensions. Aborting.\n");
        return 1;
    }
    
    // Transpose the event data (allows coalesced access pattern in E-step kernel)
    // This has consecutive values being from the same dimension of the data 
    // (num_dimensions by num_events matrix)
    float* fcs_data_by_dimension  = (float*) malloc(sizeof(float)*num_events*num_dimensions);
    
    for(int e=0; e<num_events; e++) {
        for(int d=0; d<num_dimensions; d++) {
            fcs_data_by_dimension[d*num_events+e] = fcs_data_by_event[e*num_dimensions+d];
        }
    }    

    io_time += (double)(clock() - io_timer);
   
    PRINT("Number of events: %d\n",num_events);
    PRINT("Number of dimensions: %d\n",num_dimensions);
    PRINT("Number of target clusters: %d\n\n",num_clusters);
   
    cpu_timer = clock();
    
    // Setup the cluster data structures on host
    clusters_t clusters;
    clusters.N = (float*) malloc(sizeof(float)*num_clusters);
    clusters.pi = (float*) malloc(sizeof(float)*num_clusters);
    clusters.constant = (float*) malloc(sizeof(float)*num_clusters);
    clusters.avgvar = (float*) malloc(sizeof(float)*num_clusters);
    clusters.means = (float*) malloc(sizeof(float)*num_dimensions*num_clusters);
    clusters.R = (float*) malloc(sizeof(float)*num_dimensions*num_dimensions*num_clusters);
    clusters.Rinv = (float*) malloc(sizeof(float)*num_dimensions*num_dimensions*num_clusters);
    clusters.memberships = (float*) malloc(sizeof(float)*num_events*num_clusters);
    if(!clusters.means || !clusters.R || !clusters.Rinv || !clusters.memberships) { 
        printf("ERROR: Could not allocate memory for clusters.\n"); 
        return 1; 
    }
    DEBUG("Finished allocating memory on host for clusters.\n");
    
    float rissanen;
    
    //////////////// Initialization done, starting kernels //////////////// 
    DEBUG("Invoking seed_clusters kernel.\n");
    fflush(stdout);

    // seed_clusters sets initial pi values, 
    // finds the means / covariances and copies it to all the clusters
    // TODO: Does it make any sense to use multiple blocks for this?
    seed_start = clock();
    seed_clusters(fcs_data_by_event, &clusters, num_dimensions, num_clusters, num_events);
   
    DEBUG("Invoking constants kernel.\n");
    // Computes the R matrix inverses, and the gaussian constant
    //constants_kernel<<<num_clusters, num_threads>>>(d_clusters,num_clusters,num_dimensions);
    constants(&clusters,num_clusters,num_dimensions);
    constants_iterations++;
    seed_end = clock();
    seed_total = seed_end - seed_start;
    
    // Calculate an epsilon value
    //int ndata_points = num_events*num_dimensions;
//.........这里部分代码省略.........
开发者ID:hcook,项目名称:parallel-gmm,代码行数:101,代码来源:gaussian.cpp


示例8: main

int
main(int argc, char *argv[])
{
    ps_decoder_t *ps;
    cmd_ln_t *config;
    acmod_t *acmod;
    ps_search_t *ngs, *pls;
    clock_t c;
    int32 score;
    int i;

    TEST_ASSERT(config =
            cmd_ln_init(NULL, ps_args(), TRUE,
                "-hmm", MODELDIR "/en-us/en-us",
                "-lm", MODELDIR "/en-us/en-us.lm.dmp",
                "-dict", MODELDIR "/en-us/cmudict-en-us.dict",
                "-fwdtree", "yes",
                "-fwdflat", "no",
                "-bestpath", "no",
                "-pl_window", "6",
                "-input_endian", "little",
                "-samprate", "16000", NULL));
    TEST_ASSERT(ps = ps_init(config));

    ngs = ps->search;
    pls = ps->phone_loop;
    acmod = ps->acmod;

    setbuf(stdout, NULL);
    c = clock();
    for (i = 0; i < 5; ++i) {
        FILE *rawfh;
        int16 buf[2048];
        size_t nread;
        int16 const *bptr;
        int nfr, n_searchfr;

        TEST_ASSERT(rawfh = fopen(DATADIR "/goforward.raw", "rb"));
        TEST_EQUAL(0, acmod_start_utt(acmod));
        ps_search_start(ngs);
        ps_search_start(pls);
        n_searchfr = 0;
        while (!feof(rawfh)) {
            nread = fread(buf, sizeof(*buf), 2048, rawfh);
            bptr = buf;
            while ((nfr = acmod_process_raw(acmod, &bptr, &nread, FALSE)) > 0) {
                while (acmod->n_feat_frame > 0) {
                    ps_search_step(pls, n_searchfr);
                    if (n_searchfr >= 6)
                        ps_search_step(ngs, n_searchfr - 6);
                    acmod_advance(acmod);
                    ++n_searchfr;
                }
            }
        }
        for (nfr = n_searchfr - 6; nfr < n_searchfr; ++nfr) {
            ps_search_step(ngs, nfr);
        }
        ps_search_finish(pls);
        ps_search_finish(ngs);
        printf("%s\n", ps_search_hyp(ngs, &score, NULL));

        TEST_ASSERT(acmod_end_utt(acmod) >= 0);
        fclose(rawfh);
    }
    printf("%s\n", ps_search_hyp(ngs, &score, NULL));
    TEST_EQUAL(0, strcmp("go forward ten meters", ps_search_hyp(ngs, &score, NULL)));
    c = clock() - c;
    printf("5 * fwdtree search in %.2f sec\n",
           (double)c / CLOCKS_PER_SEC);
    ps_free(ps);
    cmd_ln_free_r(config);

    return 0;
}
开发者ID:IncBin94,项目名称:pocketsphinx,代码行数:75,代码来源:test_pl_fwdtree.c


示例9: dag

/**Function*************************************************************

  Synopsis    [Performs rewriting for one node.]

  Description [This procedure considers all the cuts computed for the node
  and tries to rewrite each of them using the "forest" of different AIG
  structures precomputed and stored in the RWR manager. 
  Determines the best rewriting and computes the gain in the number of AIG
  nodes in the final network. In the end, p->vFanins contains information 
  about the best cut that can be used for rewriting, while p->pGraph gives 
  the decomposition dag (represented using decomposition graph data structure).
  Returns gain in the number of nodes or -1 if node cannot be rewritten.]
               
  SideEffects []

  SeeAlso     []

***********************************************************************/
int Rwr_NodeRewrite( Rwr_Man_t * p, Cut_Man_t * pManCut, Abc_Obj_t * pNode, int fUpdateLevel, int fUseZeros, int fPlaceEnable )
{
    int fVeryVerbose = 0;
    Dec_Graph_t * pGraph;
    Cut_Cut_t * pCut;//, * pTemp;
    Abc_Obj_t * pFanin;
    unsigned uPhase;
    unsigned uTruthBest = 0; // Suppress "might be used uninitialized"
    unsigned uTruth;
    char * pPerm;
    int Required, nNodesSaved;
    int nNodesSaveCur = -1; // Suppress "might be used uninitialized"
    int i, GainCur, GainBest = -1;
    int clk, clk2;//, Counter;

    p->nNodesConsidered++;
    // get the required times
    Required = fUpdateLevel? Abc_ObjRequiredLevel(pNode) : ABC_INFINITY;

    // get the node's cuts
clk = clock();
    pCut = (Cut_Cut_t *)Abc_NodeGetCutsRecursive( pManCut, pNode, 0, 0 );
    assert( pCut != NULL );
p->timeCut += clock() - clk;

//printf( " %d", Rwr_CutCountNumNodes(pNode, pCut) );
/*
    Counter = 0;
    for ( pTemp = pCut->pNext; pTemp; pTemp = pTemp->pNext )
        Counter++;
    printf( "%d ", Counter );
*/
    // go through the cuts
clk = clock();
    for ( pCut = pCut->pNext; pCut; pCut = pCut->pNext )
    {
        // consider only 4-input cuts
        if ( pCut->nLeaves < 4 )
            continue;
//            Cut_CutPrint( pCut, 0 ), printf( "\n" );

        // get the fanin permutation
        uTruth = 0xFFFF & *Cut_CutReadTruth(pCut);
        pPerm = p->pPerms4[ (int)p->pPerms[uTruth] ];
        uPhase = p->pPhases[uTruth];
        // collect fanins with the corresponding permutation/phase
        Vec_PtrClear( p->vFaninsCur );
        Vec_PtrFill( p->vFaninsCur, (int)pCut->nLeaves, 0 );
        for ( i = 0; i < (int)pCut->nLeaves; i++ )
        {
            pFanin = Abc_NtkObj( pNode->pNtk, pCut->pLeaves[(int)pPerm[i]] );
            if ( pFanin == NULL )
                break;
            pFanin = Abc_ObjNotCond(pFanin, ((uPhase & (1<<i)) > 0) );
            Vec_PtrWriteEntry( p->vFaninsCur, i, pFanin );
        }
        if ( i != (int)pCut->nLeaves )
        {
            p->nCutsBad++;
            continue;
        }
        p->nCutsGood++;

        {
            int Counter = 0;
            Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
                if ( Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) == 1 )
                    Counter++;
            if ( Counter > 2 )
                continue;
        }

clk2 = clock();
/*
        printf( "Considering: (" );
        Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
            printf( "%d ", Abc_ObjFanoutNum(Abc_ObjRegular(pFanin)) );
        printf( ")\n" );
*/
        // mark the fanin boundary 
        Vec_PtrForEachEntry( Abc_Obj_t *, p->vFaninsCur, pFanin, i )
            Abc_ObjRegular(pFanin)->vFanouts.nSize++;
//.........这里部分代码省略.........
开发者ID:mrkj,项目名称:abc,代码行数:101,代码来源:rwrEva.c


示例10: ClearVector

bool CSyntaxHolder::GetSentencesFromSynAn(string str, bool bFile)
{
	clock_t t1,t2;
	int CountOfWords;
	
	
	try {
		m_Synan.ClearSentences();
		ClearVector(m_PlmLines.m_Items);

		if (!GetMorphology(str, bFile, CountOfWords))
			return false;;

        #ifdef _DEBUG
		    m_PlmLines.SaveToFile("before.lem");
        #endif
		// ============  Postmorphology =======================

		CPlmLineCollection MapostPlmLines;
		if (m_bTimeStatis) t1= clock();

		if (!m_pPostMorph->ProcessData(&m_PlmLines, MapostPlmLines))
		{
			fprintf (stderr, "  Cannot process Mapost\n");
			return false;

		};;
		if (m_bTimeStatis) 
		{
			t2 = clock();
			double speed =  ((double)CountOfWords)/((t2-t1)/((double)CLOCKS_PER_SEC));
			fprintf(stderr,"Mapost: Ticks = %i Speed = %6.0f\n", t2-t1, speed );
		};


#ifdef _DEBUG
		MapostPlmLines.SaveToFile("after.lem");
#endif
		
		    
		// ============  Syntax =======================
		if (m_bTimeStatis) t1= clock();
		if (!m_Synan.ProcessData(&MapostPlmLines))
		{
			fprintf (stderr, "  Synan has crushed!\n");
			return false;
		};

		if (m_bTimeStatis) 
		{
			t2 = clock();
			double speed =  ((double)CountOfWords)/((t2-t1)/((double)CLOCKS_PER_SEC));
			fprintf(stderr,"Synan: Ticks = %i Speed = %6.0f\n", t2-t1, speed );
		};
		

		return true;
	}
	catch (...)
	{
		return false;
	};
}
开发者ID:arcady-chugunov,项目名称:thesis,代码行数:63,代码来源:SyntaxHolder.cpp


示例11: RotatePointList

void RotatePointList (g3sPoint *dest, vmsVector *src, g3sNormal *norms, int n, int o)
{
	fVector	*pfv = gameData.models.fPolyModelVerts + o;
	float		fScale;
#if PROFILING
	time_t	t = clock ();
#endif

dest += o;
if (norms)
	norms += o;
while (n--) {
	dest->p3_key = (short) o;
#if 1
	if (norms) {
		if (norms->nFaces > 1) {
			norms->vNormal.p.x /= norms->nFaces;
			norms->vNormal.p.y /= norms->nFaces;
			norms->vNormal.p.z /= norms->nFaces;
			norms->nFaces = 1;
			VmVecNormalizef (&norms->vNormal, &norms->vNormal);
			}
		dest->p3_normal = *norms++;
		}
	else
#endif
		dest->p3_normal.nFaces = 0;
	fScale = (gameData.models.nScale ? f2fl (gameData.models.nScale) : 1) / 65536.0f;
	if (gameStates.ogl.bUseTransform) {
		pfv->p.x = src->p.x * fScale;
		pfv->p.y = src->p.y * fScale;
		pfv->p.z = src->p.z * fScale;
		}
	else {
		if (gameData.models.nScale) {
			vmsVector v = *src;
			VmVecScale (&v, gameData.models.nScale);
#if 1
			G3TransformPoint (&dest->p3_vec, &v, 0);
#else
			G3TransformAndEncodePoint (dest, &v);
#endif
			}
		else {
#if 1
			G3TransformPoint (&dest->p3_vec, src, 0);
#else
			G3TransformAndEncodePoint (dest, src);
#endif
			}
		pfv->p.x = (float) dest->p3_vec.p.x / 65536.0f;
		pfv->p.y = (float) dest->p3_vec.p.y / 65536.0f;
		pfv->p.z = (float) dest->p3_vec.p.z / 65536.0f;
		}
	dest->p3_index = o++;
	dest->p3_src = *src++;
	dest++;
	pfv++;
	}
#if PROFILING
tTransform += clock () - t;
#endif
}
开发者ID:paud,项目名称:d2x-xl,代码行数:63,代码来源:interp.c


示例12: main

void main()
{
	clrscr();
	int time;
	int i,j,k;
	clock_t tic=clock();
	cout<<"::MineSweeper::"<<endl;
	cout<<"\n Press ENTER to start the game.";
	for(i=0;i<10;i++)
		for(j=0;j<10;j++)
			a[i][j]='.';
	getch();
	clock_t toc=clock();
	time=((toc-tic)*4)+3;
//	cout<<"\n Time= "<<time<<endl;
	place_mine(time);
	time=((toc-tic)*4)+3;
//	cout<<"\n Time= "<<time<<endl;
	place_1(time);
	time=((toc-tic)*7)+1;
//	cout<<"\n Time= "<<time<<endl;
	place_2(time);

//	for(i=0;i<10;i++)
//	{
//		if(i==0)
//			cout<<" ";
//		cout<<"  "<<i;
//	}
	cout<<endl;
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
//			if(j==0)
//				cout<<i;
			cout<<"  "<<a[i][j];
		}
		cout<<endl;
	}

	for(i=0;i<10;i++)
	{
		cout<<bomb[i][0]<<" "<<bomb[i][1]<<"||";
	}
	getch();

	player();

	clrscr();
	cout<<"::MineSweeper::"<<endl;
	cout<<endl;
	for(i=0;i<10;i++)
	{
		if(i==0)
			cout<<" ";
		cout<<"  "<<i;
	}
	cout<<endl;
	for(i=0;i<10;i++)
	{
		for(j=0;j<10;j++)
		{
			if(j==0)
				cout<<i;
			cout<<"  "<<user[i][j];
		}
		cout<<endl;
	}
	cout<<"\n You took "<<f_count<<" chances";

	getch();
}
开发者ID:tushar8049,项目名称:C-Program,代码行数:73,代码来源:MINESWEEPER.CPP


示例13: get_random

int get_random(int low, int high)
{
	srand(clock());
	return low + (rand() % (high - low + 1));
}
开发者ID:chadhao,项目名称:Programming1,代码行数:5,代码来源:task0002.c


示例14: sscanf

void *cal_thread(void *p)
{
	/*
	int *ips = (int *)p;
	sscanf(p->id, "%d", ip);
	*/
	int ic;
	int jc;
	int kc;
	int ip;
	int ii;
	int im;
	unsigned int WriteLen;
	unsigned long looptmp;
	unsigned long loop;
	unsigned long maxi;
	int counter=0;
	THREADS_STRUCT *pt = (THREADS_STRUCT *)p;
	double sum=0.0;
	double Totalrealsec=0.0;
	double Totaliorealsec=0.0;
	double Totalsec=0.0;
	double Totalmemsize=0.0;
	double *b;
	struct timeval startTime, endTime, ioTime;
	clock_t startClock, endClock, ioClock;

	ip      = pt->id;
	looptmp = pt->loop;
	maxi    = pt->maxi;
#ifdef DEBUG
	printf(" looptmp = %ld , ip = %d \n",looptmp,ip);
	printf(" maxi    = %ld , ip = %d \n",maxi,ip);
	printf(" maxi pt = %ld , ip = %d \n",pt->maxi,ip);
#endif
	Totalrealsec   = 0.0;
	Totaliorealsec = 0.0;
	Totalsec       = 0.0;
	Totalmemsize   = 0.0;

	if(looptmp == 0){
		loop = 10000000;
	} else {
		loop = looptmp;
	}
	for(ii = 0 ;ii < loop ; ii++){

#ifdef DEBUG
	printf(" ii = %d ,ip = %d \n",ii,ip);
	printf(" loop = %ld ,ip = %d \n",loop,ip);
	printf(" maxi = %ld ,ip = %d \n",maxi,ip);
#endif
		sum = 0.0;

		gettimeofday(&startTime, NULL);
		startClock = clock();

		if(maxi < 3){
			maxi = 4;
		}
		for(im = (maxi-1);im<maxi;im++){
			b = (double *)malloc((sizeof(double))*im*im*im);
			if( b == NULL) {
				err(EXIT_FAILURE, "can not create thread 2" );
			}
				
			for(ic=0;ic<im;ic++){
				for(jc=0;jc<im;jc++){
					for(kc=0;kc<im;kc++){
						b[ic*jc*kc] = 0.0; 
					}
				}
			}
			for(ic=0;ic<im;ic++){
				b[ic] = 1.0; 
			}
			for(ic=1;ic<(im-1);ic++){
				for(jc=1;jc<(im-1);jc++){
					for(kc=1;kc<(im-1);kc++){
						sum = sum + (b[ic*jc*kc] + b[(ic-1)*jc*kc] + b[(ic+1)*jc*kc] 
						                     	+ b[ic*(jc-1)*kc] + b[ic*(jc+1)*kc] 
                                                                     	+ b[ic*jc*(kc-1)] + b[ic*jc*(kc+1)] 
                                                    	)/7.0; 
					}
				}
			}
			for(ic=0;ic<im;ic++){
				b[ic] = sum; 
			}
	
			gettimeofday(&ioTime, NULL);
			ioClock = clock();
	
			if(pt->arg1 == 1){
				WriteLen = (int)((im*im*im)-1);
				fwrite((char *)b,sizeof(char),WriteLen,pt->fp);
				fseek(pt->fp,  0L, SEEK_SET);
			}

			free(b);
//.........这里部分代码省略.........
开发者ID:ohta-hpcs,项目名称:StressTest,代码行数:101,代码来源:main3.c


示例15: run_test_case

	int run_test_case(int casenum__) {
		switch (casenum__) {
		case 0: {
			int blockHeights[]        = {4,7};
			int expected__            = 11;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 1: {
			int blockHeights[]        = {7,4};
			int expected__            = 7;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 2: {
			int blockHeights[]        = {7};
			int expected__            = 7;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 3: {
			int blockHeights[]        = {4};
			int expected__            = 4;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 4: {
			int blockHeights[]        = {48,1,50,1,50,1,48};
			int expected__            = 196;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 5: {
			int blockHeights[]        = {49,2,49,2,49};
			int expected__            = 147;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
		case 6: {
			int blockHeights[]        = {44,3,44,3,44,47,2,47,2,47,2};
			int expected__            = 273;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}

		// custom cases

      case 7: {
          int blockHeights[]        = {2, 1, 1, 33, 40};
			int expected__            = 42;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
      case 8: {
          int blockHeights[]        = {11, 6, 6, 6};
			int expected__            = 18;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}
/*      case 9: {
			int blockHeights[]        = ;
			int expected__            = ;

			clock_t start__           = clock();
			int received__            = BlockTower().getTallest(vector <int>(blockHeights, blockHeights + (sizeof blockHeights / sizeof blockHeights[0])));
			return verify_case(casenum__, expected__, received__, clock()-start__);
		}*/
		default:
			return -1;
		}
	}
开发者ID:juancate,项目名称:CompetitivePrograming,代码行数:89,代码来源:BlockTower.cpp


示例16: inpaint_image

nTupleVolume * inpaint_image( nTupleVolume *imgVolIn, nTupleVolume *occVolIn,
patchMatchParameterStruct *patchMatchParams, inpaintingParameterStruct *inpaintingParams)
{
	
	// ******************************************************************** //
	// **** AUTOMATICALLY DETERMINE NUMBER OF LEVELS, IF NOT SPECIFIED **** //
	// ******************************************************************** //
	if (inpaintingParams->nLevels == -1)
	{
		inpaintingParams->nLevels =
			determine_multiscale_level_number(occVolIn,imgVolIn->patchSizeX,imgVolIn->patchSizeY);
	}
	display_inpainting_parameters(inpaintingParams);
	display_patch_match_parameters(patchMatchParams);
	
	nTupleVolume *imgVolOut;

	// ************************** //
	// **** CREATE PYRDAMIDS **** //
	// ************************** //
	nTupleVolumePyramid imgVolPyramid = create_nTupleVolume_pyramid(imgVolIn, inpaintingParams->nLevels);
	nTupleVolumePyramid occVolPyramid = create_nTupleVolume_pyramid_binary(occVolIn, inpaintingParams->nLevels);
	featurePyramid featuresVolPyramid;
	if (inpaintingParams->useFeatures == true)
	{
		double t1 = clock();
		featuresVolPyramid = create_feature_pyramid(imgVolIn, occVolIn, inpaintingParams->nLevels);
		MY_PRINTF("\n\nFeatures calculation time: %f\n",((double)(clock()-t1)) / CLOCKS_PER_SEC);
	}
	else
	{
		featuresVolPyramid.normGradX = NULL;
        featuresVolPyramid.normGradY = NULL;
        featuresVolPyramid.nLevels = -1;
	}

	//create structuring element
	nTupleVolume *structElDilate = create_structuring_element("rectangle", imgVolIn->patchSizeX, imgVolIn->patchSizeY);
	
	//show_patch_match_parameters(patchMatchParams);
	
	// ****************************************** //
	// ************* START INPAINTING *********** //
	// ****************************************** //
	
	nTupleVolume *imgVol,*normGradXvol,*normGradYvol;
	nTupleVolume *shiftVol=NULL;
	for (int level=( (inpaintingParams->nLevels)-1); level>=0; level--)
	{
		printf("Current pyramid level : %d\n",level);
		nTupleVolume *imgVolPrevious,*occVol,*occVolDilate;

		if (patchMatchParams->maxShiftDistance != -1)		
			patchMatchParams->maxShiftDistance =
			(float)( (patchMatchParams->maxShiftDistance)/( pow((float)SUBSAMPLE_FACTOR,(float)level) ));
		
		imgVol = copy_image_nTuple(imgVolPyramid[level]);
		occVol = copy_image_nTuple(occVolPyramid[level]);
		//create dilated occlusion
		occVolDilate = imdilate(occVol, structElDilate);
		
		if (featuresVolPyramid.nLevels >= 0)
		{
			normGradXvol = copy_image_nTuple((featuresVolPyramid.normGradX)[level]);
			normGradYvol = copy_image_nTuple((featuresVolPyramid.normGradY)[level]);
			//attach features to patchMatch parameters
			patchMatchParams->normGradX = normGradXvol;
			patchMatchParams->normGradY = normGradYvol;
		}
					
		//initialise solution
		if (level == ((inpaintingParams->nLevels)-1))
		{
			shiftVol = new nTupleVolume(4,imgVol->xSize,imgVol->ySize,imgVol->patchSizeX,imgVol->patchSizeY,IMAGE_INDEXING);
			shiftVol->set_all_image_values(0);
			printf("\nInitialisation started\n\n\n");
			initialise_inpainting(imgVol,occVol,featuresVolPyramid,shiftVol,patchMatchParams);
			patchMatchParams->partialComparison = 0;
			printf("\nInitialisation finished\n\n\n");
			
			if (featuresVolPyramid.nLevels >= 0)	//retrieve features from the pointers in the patchMatch parameters
			{
				normGradXvol = patchMatchParams->normGradX;
				normGradYvol = patchMatchParams->normGradY;
			}
		}
		else	//reconstruct current solution
		{
			if (featuresVolPyramid.nLevels >= 0)
			{
				reconstruct_image_and_features(imgVol, occVol,
				normGradXvol, normGradYvol,
				shiftVol, SIGMA_COLOUR);
			}
			else
			{
				reconstruct_image(imgVol,occVol,shiftVol,SIGMA_COLOUR);
				//write_shift_map(shiftVol,fileOut);
			}
		}
//.........这里部分代码省略.........
开发者ID:alasdairnewson,项目名称:Inpainting_ipol_code,代码行数:101,代码来源:image_inpainting.cpp


示例17: run_epd_testsuite

void run_epd_testsuite(void)
{
  FILE *testsuite;
  char readbuff[2000];
  char testname[FILENAME_MAX];
  char tempbuff[2000];
  float elapsed; 
  int nps;
  long thinktime;
	move_s comp_move;
  int tested, found;
	
  clock_t cpu_start, cpu_end;
  
  tested = 0;
  found = 0;
  
  printf("\nName of EPD testsuite: ");
  rinput(testname, STR_BUFF, stdin);
  printf("\nTime per move (s): ");
  rinput(readbuff, STR_BUFF, stdin);
  thinktime = atol(readbuff);
  printf("\n");

  thinktime *= 100;

  testsuite = fopen(testname, "r");

  while (fgets(readbuff, 2000, testsuite) != NULL)
    {
      tested++;

      setup_epd_line(readbuff);

      root_to_move = ToMove;
      
      clear_tt();
      initialize_hash();
      
      display_board(stdout, 1); 
 
      forcedwin = FALSE;    
    //  pn_time = thinktime;
    //  cpu_start = clock();
    //  proofnumbersearch();
    //  cpu_end = clock();
     // rdelay(2);
     
     elapsed = (cpu_end-cpu_start)/(double) CLOCKS_PER_SEC;
     printf("Time: %f\n", elapsed);
      
     if (interrupt()) rinput(tempbuff, STR_BUFF, stdin);
      
      fixed_time = thinktime;
      
       cpu_start = clock();
       comp_move = think();
       cpu_end = clock();
      

      printf ("\nNodes: %ld (%0.2f%% qnodes)\n", nodes,
	      (float) ((float) qnodes / (float) nodes * 100.0));
      
      elapsed = (cpu_end-cpu_start)/(float) CLOCKS_PER_SEC;
      nps = (int)((float) nodes/(float) elapsed);
      
      if (!elapsed)
	printf ("NPS: N/A\n");
      else
	printf ("NPS: %ld\n", (long int) nps);
      
      printf("ECacheProbes : %ld   ECacheHits : %ld   HitRate : %f%%\n", 
	     ECacheProbes, ECacheHits, 
	     ((float)ECacheHits/((float)ECacheProbes+1)) * 100);
      
      printf("TTStores : %ld TTProbes : %ld   TTHits : %ld   HitRate : %f%%\n", 
	     TTStores, TTProbes, TTHits, 
	     ((float)TTHits/((float)TTProbes+1)) * 100);
      
      printf("NTries : %d  NCuts : %d  CutRate : %f%%  TExt: %d\n", 
	     NTries, NCuts, (((float)NCuts*100)/((float)NTries+1)), TExt);
      
      printf("Check extensions: %ld  Razor drops : %ld  Razor Material : %ld\n", ext_check, razor_drop, razor_material);
      printf("EGTB Hits: %d  EGTB Probes: %d  Efficiency: %3.1f%%\n", EGTBHits, EGTBProbes,
             (((float)EGTBHits*100)/(float)(EGTBProbes+1)));		 
      
      printf("Move ordering : %f%%\n", (((float)FHF*100)/(float)FH+1));
      
      printf("Material score: %d   Eval : %ld\n", Material, eval());
      printf("\n");
     
      if (!forcedwin)
      {
      if(check_solution(readbuff, comp_move))
	{
	  found++;
	  printf("Solution found.\n");
	}
      else
	{
//.........这里部分代码省略.........
开发者ID:gcp,项目名称:sjeng,代码行数:101,代码来源:epd.c


示例18: main

/* Corpo de leitura do arquivo adaptado do arquivo filtro_windows.c no repositório. */
int main(int argc, char *argv[])
{
    clock_t start, end;
    double cpu_time_used;
    char filetype[256], *ptri, *ptro, *img;
    char rnds[SIMD_SIZE];
    char limit[SIMD_SIZE];
    int width, height, depth, pixels, i, j, k, n, resto, siz, rnd;

	char mult[24] = {
		1, 1, 3, 1, 1, 3, 1, 1,
		3, 1, 1, 3, 1, 1, 3, 1,
		1, 3, 1, 1, 3, 1, 1, 3 }; // vetor com as 3 sequencias de multiplicadores usadas (apos a 3a sequencia, a 4a iguala-se a primeira, entao reiniciamos)

	char *m = mult;
	
	char clear[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; // bytes auxiliares
	char xorFix[] = { 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80 }; // bytes 128 para corrigir a comparacao
		
    FILE *fp;
    FILE *fo;
 
    if (argc < 3)
    {
        printf("Usage: %s input output", argv[0]);
        exit(1);
    }

    fp = fopen(argv[1], "rb");
    if (!fp)
    {
        printf("File %s not found!", argv[1]);
        exit(1);
    }

    fo = fopen(argv[2], "wb");
    if (!fo)
    {
        printf("Unable to create file %s!", argv[2]);
        exit(1);
    }

    srand((unsigned)time(NULL)); // para valores randomicos

    fscanf(fp, "%s\n", filetype);
    fprintf(fo, "%s%c", filetype, 10);

    fscanf(fp, "%d %d\n%d\n", &width, &height, &depth);
    fprintf(fo, "%d %d\n%d%c", width, height, depth, 10);

    pixels = width * height;
    
    siz = (pixels * 3) + (SIMD_SIZE - ((3 * pixels) % SIMD_SIZE)); // fazemos o tamanho do malloc ser divisivel por SIMD_SIZE, adicionando o que falta ao resto

    ptri = ptro = img = (char *)malloc(siz);

    fread(img, 3, pixels, fp);
    
    start = clock();

    for (j = 0; j < SIMD_SIZE; j++)
        limit[j] = RND_LIMIT; // preenchemos o vetor que limita a subtracao do ruido com 50

    for (i = 0; i < (siz / SIMD_SIZE); i++) // precisamos de me 

鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ clock_boottime_or_monotonic函数代码示例发布时间:2022-05-30
下一篇:
C++ clnttcp_create函数代码示例发布时间: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