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


C++ SimpleTimer类代码示例

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


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

示例1: karbtest

template <class T> bool
karbtest (Connector<T>* rc) {

	GradientParams gp;

	std::string in_file;// = std::string (base + "/" + std::string(rc->GetElement("/config/data-in")->Attribute("fname")));
	std::string out_file;// = std::string (base + "/" + rc->GetElement("/config/data-out")->Attribute("fname"));

	bool   simann  = false;
	size_t hpoints = 1;
	rc->Attribute ("simann",   &simann);
	rc->Attribute ("hpoints",  &hpoints);

	if (simann) {

		double coolrate, startt, finalt;
		size_t coolit;
		bool   verbose, exchange;
		
		rc->Attribute ("coolrate", &coolrate);
		rc->Attribute ("startt",   &startt);
		rc->Attribute ("finalt",   &finalt);
		rc->Attribute ("coolit",   &coolit);
		rc->Attribute ("verbose",  &verbose);
		rc->Attribute ("exchange", &exchange);
		
		SimulatedAnnealing sa (gp.k, coolit, startt, finalt, coolrate, verbose, exchange);
		sa.Cool();
		gp.k = sa.GetSolution();
		
	}
	
	rc->Attribute ("maxgrad", &(gp.mgr));
	rc->Attribute ("maxslew", &(gp.msr));
	rc->Attribute ("dt",      &(gp.dt));
	
	rc->Attribute ("gunits",  &(gp.gunits));
	rc->Attribute ("lunits",  &(gp.lunits));
	
	Matrix<double> x  = linspace<double> (0.0,1.0,size(gp.k,0));
	Matrix<double> xi = linspace<double> (0.0,1.0,size(gp.k,0)*hpoints);

	gp.k = interp1 (x, gp.k, xi, INTERP::AKIMA);

	printf ("\nComputing trajectory for ... \n");
	printf ("    [maxgrad: %.2f, maxslew: %.2f, dt: %.2e]\n\n", gp.mgr, gp.msr, gp.dt);
	
    SimpleTimer st ("VD spiral design");
	Solution s = ComputeGradient (gp);
    st.Stop();
	
    IOContext f = fopen (out_file.c_str(), WRITE);
    s.dump (f);
    fclose (f);
	

	return true;

}
开发者ID:nomissretep,项目名称:codeare,代码行数:59,代码来源:karb.hpp

示例2: main

int main( int , char** ) {
	SimpleTimer timer;

	timer.tic();
	DoubleVector a(5);
	a[0] = 1;
	a[1] = 3;
	a[2] = 5;
	a[3] = 7;
	a[4] = 9;
	DoubleVector b = a;
	a.steady(1);
	DoubleVector c = a+b+a*a+a;
	a += b+a*a+a;
	qDebug() << "------------" << timer.tic();
	qDebug() << a[0] << a[1] << a[2] << a[3] << a[4] ;
	qDebug() << c[0] << c[1] << c[2] << c[3] << c[4] ;

	qDebug() << "------------";
	int row = 2;
	int col = 3;
	DoubleMatrix m1( row, col );
	for( int i=0; i<row; i++ ) {
		for( int j=0; j<col; j++ ) {
			m1[i][j] = i+j;
		}
	}
	for( int i=0; i<row; i++ ) {
		for( int j=0; j<col; j++ ) {
			cout << m1[i][j] << " ";
		}
		cout << endl;
	}
	timer.tic();
	DoubleMatrix m2 = m1 + m1;
	m1.steady( row-1, col-1 );
	m1 %= m2;
	qDebug() << "------------" << timer.tic();

	for( int i=0; i<row; i++ ) {
		for( int j=0; j<col; j++ ) {
			cout << m2[i][j] << " ";
		}
		cout << endl;
	}
	qDebug() << "------------";
	for( int i=0; i<row; i++ ) {
		for( int j=0; j<col; j++ ) {
			cout << m1[i][j] << " ";
		}
		cout << endl;
	}

	return 0;
}
开发者ID:BackupTheBerlios,项目名称:nnfw-svn,代码行数:55,代码来源:algebra1.cpp

示例3: EDITOR_SCENE_SCOPE_TIMER

UndoCommandPtr Selection::AddItems(const OS_ObjectDumbPtr &items, const SelectionChangingSignature::Delegate& emitterChanging, const SelectionChangedSignature::Delegate& emitterChanged)
{
	if ( items.Empty() )
	{
		return NULL;
	}

	EDITOR_SCENE_SCOPE_TIMER( ("") );

	SimpleTimer timer;

	std::vector<Reflect::Object*> added;
	OS_ObjectDumbPtr temp = m_Items;
	OS_ObjectDumbPtr::Iterator itr = items.Begin();
	OS_ObjectDumbPtr::Iterator end = items.End();
	for ( ; itr != end; ++itr )
	{
		if ( temp.Append(*itr) )
		{
			added.push_back(*itr);
		}
	}

	UndoCommandPtr command;

	if ( !temp.Empty() )
	{
		SelectionChangingArgs args ( temp );
		m_SelectionChanging.RaiseWithEmitter( args, emitterChanging );
		if ( !args.m_Veto )
		{
			command = new SelectionChangeCommand( this );

			std::vector<Reflect::Object*>::iterator itr = added.begin();
			std::vector<Reflect::Object*>::iterator end = added.end();
			for ( ; itr != end; ++itr )
			{
				SceneNode *pSceneNode = Reflect::SafeCast<SceneNode>(*itr);
				if (pSceneNode)
				{
					pSceneNode->SetSelected(true);
				}
			}

			m_Items = temp;

			m_SelectionChanged.RaiseWithEmitter(m_Items, emitterChanged);
		}
	}

	Log::Profile( TXT( "Selection AddItems took %fms\n" ), timer.Elapsed());

	return command;
}
开发者ID:pmatyja,项目名称:Helium,代码行数:54,代码来源:Selection.cpp

示例4: SCOPE_CYCLE_COUNTER

void FNiagaraSimulation::Tick(float DeltaSeconds)
{
	SCOPE_CYCLE_COUNTER(STAT_NiagaraTick);
	SimpleTimer TickTime;

	UNiagaraEmitterProperties* PinnedProps = Props.Get();
	if (!PinnedProps || !bIsEnabled || TickState == NTS_Suspended || TickState == NTS_Dead)
	{
		return;
	}

	Age += DeltaSeconds;

	check(Data.GetNumVariables() > 0);
	check(PinnedProps->SpawnScriptProps.Script);
	check(PinnedProps->UpdateScriptProps.Script);
	
	TickEvents(DeltaSeconds);

	// Figure out how many we will spawn.
	int32 OrigNumParticles = Data.GetNumInstances();
	int32 NumToSpawn = CalcNumToSpawn(DeltaSeconds);
	int32 MaxNewParticles = OrigNumParticles + NumToSpawn;
	Data.Allocate(MaxNewParticles);

	ExternalConstants.SetOrAdd(BUILTIN_CONST_EMITTERAGE, FVector4(Age, Age, Age, Age));
	ExternalConstants.SetOrAdd(BUILTIN_CONST_DELTATIME, FVector4(DeltaSeconds, DeltaSeconds, DeltaSeconds, DeltaSeconds));

	// Simulate particles forward by DeltaSeconds.
	if (TickState==NTS_Running || TickState==NTS_Dieing)
	{
		SCOPE_CYCLE_COUNTER(STAT_NiagaraSimulate);
		RunVMScript(PinnedProps->UpdateScriptProps, EUnusedAttributeBehaviour::PassThrough);
	}

	//Init new particles with the spawn script.
	if (TickState==NTS_Running)
	{
		SCOPE_CYCLE_COUNTER(STAT_NiagaraSpawn);
		Data.SetNumInstances(MaxNewParticles);
		//For now, zero any unused attributes here. But as this is really uninitialized data we should maybe make this a more serious error.
		RunVMScript(PinnedProps->SpawnScriptProps, EUnusedAttributeBehaviour::Zero, OrigNumParticles, NumToSpawn);

		if (bGenerateSpawnEvents)
		{
			SpawnEventGenerator.OnSpawned(OrigNumParticles, NumToSpawn);
		}
	}


	CPUTimeMS = TickTime.GetElapsedMilliseconds();

	INC_DWORD_STAT_BY(STAT_NiagaraNumParticles, Data.GetNumInstances());
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:54,代码来源:NiagaraSimulation.cpp

示例5: main

int main()
{
    SimpleTimer timer;

    cout << "Begin timer!" << endl;
    timer.Start();

    sleep( 2 );

    cout << "Elapsed time: " << timer.GetElapsed() << endl;

    return 0;
}
开发者ID:Rachels-Courses,项目名称:CPP-Course,代码行数:13,代码来源:main.cpp

示例6: SCOPE_CYCLE_COUNTER

/** Update render data buffer from attributes */
FNiagaraDynamicDataBase *NiagaraEffectRendererSprites::GenerateVertexData(const FNiagaraEmitterParticleData &Data)
{
	SCOPE_CYCLE_COUNTER(STAT_NiagaraGenSpriteVertexData);

	SimpleTimer VertexDataTimer;

	FNiagaraDynamicDataSprites *DynamicData = new FNiagaraDynamicDataSprites;
	TArray<FParticleSpriteVertex>& RenderData = DynamicData->VertexData;

	RenderData.Reset(Data.GetNumParticles());
	//CachedBounds.Init();

	const FVector4 *PosPtr = Data.GetAttributeData("Position");
	const FVector4 *ColPtr = Data.GetAttributeData("Color");
	const FVector4 *AgePtr = Data.GetAttributeData("Age");
	const FVector4 *RotPtr = Data.GetAttributeData("Rotation");
	uint32 NumSubImages = 1;
	if (Properties)
	{
		NumSubImages = Properties->SubImageInfo.X*Properties->SubImageInfo.Y;
	}
	float ParticleId = 0.0f, IdInc = 1.0f / Data.GetNumParticles();
	RenderData.AddUninitialized(Data.GetNumParticles());
	for (uint32 ParticleIndex = 0; ParticleIndex < Data.GetNumParticles(); ParticleIndex++)
	{
		FParticleSpriteVertex& NewVertex = RenderData[ParticleIndex];
		NewVertex.Position = PosPtr[ParticleIndex];
		NewVertex.OldPosition = NewVertex.Position;
		NewVertex.Color = FLinearColor(ColPtr[ParticleIndex]);
		NewVertex.ParticleId = ParticleId;
		ParticleId += IdInc;
		NewVertex.RelativeTime = AgePtr[ParticleIndex].X;
		NewVertex.Size = FVector2D(RotPtr[ParticleIndex].Y, RotPtr[ParticleIndex].Z);
		NewVertex.Rotation = RotPtr[ParticleIndex].X;
		NewVertex.SubImageIndex = RotPtr[ParticleIndex].W * NumSubImages;

		FPlatformMisc::Prefetch(PosPtr + ParticleIndex+1);
		FPlatformMisc::Prefetch(RotPtr + ParticleIndex + 1);
		FPlatformMisc::Prefetch(ColPtr + ParticleIndex + 1);		
		FPlatformMisc::Prefetch(AgePtr + ParticleIndex + 1);

		//CachedBounds += NewVertex.Position;
	}
	//CachedBounds.ExpandBy(MaxSize);

	CPUTimeMS = VertexDataTimer.GetElapsedMilliseconds();


	return DynamicData;
}
开发者ID:kidaa,项目名称:UnrealEngineVR,代码行数:51,代码来源:NiagaraEffectRenderer.cpp

示例7: HELIUM_EDITOR_SCENE_SCOPE_TIMER

void CreateTool::CreateMultipleObjects( bool stamp )
{
	HELIUM_EDITOR_SCENE_SCOPE_TIMER( "Place Multiple Instances At Location" );

	if ( m_InstanceRadius <= 0.0f )
	{
		return;
	}

	if ( m_InstanceOffsets.empty() || m_InstanceUpdateOffsets )
	{
		m_InstanceOffsets.clear();
		SetupInstanceOffsets( m_InstanceRadius, m_InstanceOffsets );
		m_InstanceUpdateOffsets = false;
	}

	float32_t maxTime = 100.0f;
	SimpleTimer instanceTimer;
	Vector3 instanceNormalOffset = m_InstanceNormal.Normalize() * 2.0f * s_PaintRadius;

	while ( m_InstanceOffsets.size() && ( stamp || ( instanceTimer.Elapsed() < maxTime ) ) )
	{
		V_Vector3::iterator itr = m_InstanceOffsets.begin();

		Matrix4 instanceTransform;
		instanceTransform.t = Vector4( *itr );
		instanceTransform *= Matrix4( AngleAxis::Rotation( Editor::SideVector, m_InstanceNormal ) );
		instanceTransform.t += Vector4( m_InstanceTranslation );

		Vector3 point = Vector3( instanceTransform.t.x, instanceTransform.t.y, instanceTransform.t.z );
		LinePickVisitor pick( m_Scene->GetViewport()->GetCamera(), Line( point + instanceNormalOffset, point - instanceNormalOffset ) );

		Vector3 instanceTranslation;
		Vector3 instanceNormal;
		if ( DetermineTranslationAndNormal( pick, instanceTranslation, instanceNormal ) )
		{
			point = Vector3( instanceTranslation.x - m_InstanceTranslation.x, instanceTranslation.y - m_InstanceTranslation.y, instanceTranslation.z - m_InstanceTranslation.z );
			if ( point.Length() <= s_PaintRadius )
			{
				CreateSingleObject( instanceTranslation, instanceNormal, true );
			}
		}

		m_InstanceOffsets.erase( itr );
	}
}
开发者ID:Fantasticer,项目名称:Helium,代码行数:46,代码来源:CreateTool.cpp

示例8: doTest

void doTest(const int numThreads, std::thread* threads, const bool stest, const bool locking)
{
	iterations = 1;
	do
	{
		SimpleTimer timer;
		timer.Start();
		//initialize testing threads, then wait for all threads to finish
		if(stest)
		{
			for(int i = 0; i < numThreads; ++i)
			{
				threads[i] = std::thread(StackSThread);
			}
		}
		else 
		{
			for(int i = 0; i < numThreads; ++i)
			{
				threads[i] = std::thread(StackTThread);
			}
		}
		for(int i = 0; i < numThreads; ++i)
		{
			threads[i].join();
		}
		timer.Stop();
		while(!stack->IsEmpty())
		{
			delete (stack->Pop());
		}
		std::cout << (locking ? "Locking " : "LockFree ") << (stest ? "STest " : "TTest ") <<
		    iterations << " inner iterations with " <<
			numThreads << " threads: " << timer.ElapsedMilliseconds() << std::endl;

		std::ofstream outfile;
		outfile.open(OUTPUT_FILE, std::ios_base::app);
		outfile << (locking ? "L," : "F,") << (stest ? "S," : "T,") << iterations << "," << numThreads << "," << timer.ElapsedMilliseconds() << std::endl;
		outfile.close();

		iterations = iterations << 1;
	}
	while(iterations < MAX_INNER_ITERATIONS);
}
开发者ID:rworr,项目名称:LockFree,代码行数:44,代码来源:StackTest.hpp

示例9: launchExpt

// this function expects that simulation params be updated beforehand
int launchExpt(){

	SimpleTimer clockExpt; clockExpt.reset();
	clockExpt.start();

	cout << "\n> Launch Experiment: " << exptDesc << "_runSet(" << iEns << ")\n";
	cout << "   > Simulate " << genMax << " generations, plot after every " << plotStep << " steps.\n   > "; 
	cout.flush();

	// start run
//	int k=0, g=0;
	while(1){	// infinite loop needed to poll anim_on signal.
		if (graphicsQual > 0) glutMainLoopEvent();		

		// animate particles
		if (b_anim_on) {
			animateParticles(); 
			++stepNum;
			if (b_displayEveryStep && stepNum % (-dispInterval) == 0) displayDevArrays();	// update display if every step update is on
		}

		// if indefinite number of steps desired, skip gen-advance check
		if (moveStepsPerGen < 0) continue;	

		// check if generation is to be advanced.
		if (stepNum >= moveStepsPerGen){
			stepNum = 0;
			advanceGen();	// Note: CudaMemCpy at start and end of advanceGen() ensure that all movement kernel calls are done
			++genNum;			
			if (genNum % plotStep == 0) { cout << "."; cout.flush(); }
		}

		// when genMax genenrations are done, end run
		if (genNum >= genMax) break;
	}

	// end run, reset counters
	cout << " > DONE. "; // << "Return to main().\n\n";
	printTime_hhmm(clockExpt.getTime());
	stepNum = genNum = 0;
	++iExpt;
	return 0;
}
开发者ID:jaideep777,项目名称:altruism,代码行数:44,代码来源:main.cpp

示例10: probingConditionsMet

bool MediaParserGst::probingConditionsMet(const SimpleTimer& timer)
{
    return foundAllStreams() || (timer.expired() && getBytesLoaded() >= MIN_PROBE_SIZE);
}
开发者ID:jlopez,项目名称:gnash,代码行数:4,代码来源:MediaParserGst.cpp

示例11: highCalibration

void ECCalibrateScreen::highCalibration()
{
	myUTFT.clrScr();
	myUTFT.setColor(255, 0, 0);
	myUTFT.fillRect(0, 0, 220, 13);
	myUTFT.setColor(255, 255, 255);
	myUTFT.setBackColor(255, 0, 0);
	myUTFT.drawLine(0, 14, 320, 14);
	myUTFT.print("EC Calibration", CENTER, 1);
	myUTFT.setBackColor(0, 0, 0);

	myUTFT.print("Calibrate now with the high side liquid", LEFT, 30);
	myUTFT.print("Place the sensor in the 3,000Us ", LEFT, 42);
	myUTFT.print("calibration liquid. This process", LEFT, 54);
	myUTFT.print("will take 5 minutes to complete", LEFT, 66);
	myUTFT.print("Wait for process to finish before ", LEFT, 78);
	myUTFT.print("removing the sensor from the liquid", LEFT, 90);
	myUTFT.print("", LEFT, 102);
	myUTFT.print("************************************", LEFT, 114);
	myUTFT.print("Touch screen to continue", CENTER, 162);

	waitForTouch();
	myUTFT.clrScr();

	inputstring = "C\r";  //set in continious mode

	myUTFT.clrScr();
	String thisSt = String(iSeconds);
	myUTFT.print("Calibration in Progress", CENTER, 30);
	myUTFT.print("Seconds left until ready " + thisSt, CENTER, 42);
	simpleTimer.setTimer(3000, updateWaitScreen, /*100*/ 4); //Update screen every 3 seconds for 5 minues.

}
开发者ID:markcgriffiths,项目名称:hydrocontroller,代码行数:33,代码来源:ECCalibrateScreen.cpp

示例12: rcb_rec2D

void rcb_rec2D(vector<T> *p_coord,
               vector<int> *p_map,
               vector<int> *p_part,
               int start,
               int end,
               int dims, 
               int cur_depth,
               int ttl_depth){

	// end of partitioning
	if(cur_depth == 0) return;

	//cout << "-------------------------------------------------------------" << endl;
	//cout << "    start=" << start << " end=" << end << " cur_depth=" << cur_depth << endl;

tmr_span.start();
	// calculate max distance on each axis
	double x_span = calc_span(p_coord, start, end, dims, 0);
	double y_span = calc_span(p_coord, start, end, dims, 1);
tmr_span.stop_and_add_to_total();;

	// choose axis
	int axis = -1;
	if(x_span >= y_span)
		axis = 0;
	else
		axis = 1;

	//cout << "    x_span=" << x_span << " y_span=" << y_span << " axis=" << axis << endl;

	// find mid-point
tmr_pivot1.start();
	T pivot = find_pivot(p_coord, start, end, dims, axis);
tmr_pivot1.stop_and_add_to_total();;
	//cout << "    pivot=" << pivot <<endl;

	// partition into two
	int level= cur_depth-1;
	int part_index = partition(p_coord, p_map, p_part, start, end, dims, axis, pivot, level);

	//cout << "    part_index=" << part_index << endl;

	// next partitioning
	rcb_rec2D(p_coord, p_map, p_part, start, start+part_index, dims, cur_depth-1, ttl_depth);
	rcb_rec2D(p_coord, p_map, p_part, start+part_index, end, dims, cur_depth-1, ttl_depth);

}
开发者ID:nao15irikiin,项目名称:Mesh-Partitioning,代码行数:47,代码来源:op_part_rcb.cpp

示例13: writeVal

boolean MyTone::writeVal( HardwareTypeIdentifier type, HardwareCommandResult* result ) {
	if(type == HWType_tone && result != NULL && result->getUint16ListNum() > 0) {
		uint16_t length = result->getUint16List()[0];

		uint8_t tone = this->myTone;
		if(result->getUint16ListNum() > 1)
		tone = result->getUint16List()[1];

		write(tone);
		int num = timer.setTimeout(length, (timer_callback) &MyTone::stopOutputHook);
		timer.setCallbackContext(num, (void*) this);

		return true;
	}

	return false;
}
开发者ID:manasdas17,项目名称:iotduino,代码行数:17,代码来源:MyTone.cpp

示例14: setup

// SETUP
void setup()
{
    // For algorithm speed checking
    loopPeriod = 0;
    lastLoop = micros();

    // Lap timer
    lapTimer.setInterval(100, IncrementTime);
    lapTimer.disable(0);

    // Initialize LCD
    lcd.begin(16, 2);   
    lcd.setCursor(0,0);
    
    // Turn signals
    pinMode(LEFT_TURN_LED, OUTPUT);
    pinMode(RIGHT_TURN_LED, OUTPUT);
    digitalWrite(LEFT_TURN_LED, 0);
    digitalWrite(RIGHT_TURN_LED, 0);
    turnSignalTimer.setInterval(50, TurnSignal);

    // Force motors off by default
    MotorSpeed(LEFT_MOTOR, 0);
    MotorSpeed(RIGHT_MOTOR, 0);

    // Parameters need to be loaded from EEPROM
    LoadFromEEPROM();

    // Intro text
    Clear();
    Cursor(TOP, 0);
    Print("FAST ORANGE");
    Cursor(BOTTOM, 0);
    #ifdef DEBUG_MODE
    Print("Debug Mode");
    #else
    Print("Race Mode");
    #endif
    delay(1000);

    currentState = menu;
}
开发者ID:johndharvey,项目名称:Robert-roving-robot,代码行数:43,代码来源:Wire+following+PID+control.cpp

示例15: setup

void setup()
{
	Serial.begin(9600);

	pinMode (11,OUTPUT);
	pinMode (12,OUTPUT);

	pinMode(8, INPUT);    // Set the switch pin as input
	pinMode(9, INPUT);    // Set the switch pin as input
	pinMode(10, INPUT);    // Set the switch pin as input


    // Pin 13 has an LED connected on most Arduino boards
    pinMode(13, OUTPUT);


    timer.setInterval(10,&debDown);
    timer.setInterval(10,&debUp);
    timer.setInterval(10,&debStop);
    timer.setInterval(10000,&clockTimer);
    mgr.moveUp();
}
开发者ID:cybertux,项目名称:theseus,代码行数:22,代码来源:shutter.cpp


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