本文整理汇总了C++中SimpleTimer::printTime方法的典型用法代码示例。如果您正苦于以下问题:C++ SimpleTimer::printTime方法的具体用法?C++ SimpleTimer::printTime怎么用?C++ SimpleTimer::printTime使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleTimer
的用法示例。
在下文中一共展示了SimpleTimer::printTime方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
const float maxeta = 5; //maximum noise parameter
float predNoise = 0.0;
const int realisations = 1; //number of realisations
const int iterations = 2000000; //number of time steps
const int last = 100; //number of last steps over which order parameter would be averaged
int c;
//int *gsd; //pointer to initialise array that stores different group size
float timeElapsed;
Store store(particles); //Store class object
store.fileOpen();
Swarm swarm(particles, systemSize, nPred);
swarm.allocate();
swarm.launchRandInit((unsigned long) t);
SimpleTimer time; time.reset();
time.start();
float avgEta = 0.0;
for (float eta = maxeta; eta <= maxeta; eta = eta + 0.2){ //loop to iterate over different noise values
store.orientationParam = 0.0; //initialize OP to zero before each round of replication
for (int rep = 0; rep < realisations; rep++){ //loop to perform more number of realizations
swarm.init(eta);
swarm.initPredator(predNoise);
swarm.initid();
swarm.initAttack();
swarm.cudaCopy();
Screen screen;
if (screen.init() == false){
cout << "error initialising SDL." << endl;
}
for (int i = 0; i < iterations; i++){ //loop to run the simulations for number of timesteps
screen.clear();
swarm.update();
const Particle * const pParticles = swarm.returnParticles(); //store the particle
for (int p = 0; p < particles; p++){
Particle particle = pParticles[p];
avgEta = avgEta + particle.eta;
}
avgEta = avgEta / particles;
for (int p = 0; p < particles; p++){
Particle particle = pParticles[p];
int x = particle.coord.x * Screen::SCREEN_WIDTH / systemSize;
int y = particle.coord.y * Screen::SCREEN_HEIGHT / systemSize;
//store.printCoord(x,y);
screen.setPixel(x, y, int(255 * particle.eta / maxeta), 0, int(255 * abs(maxeta - particle.eta) / maxeta));
}
const Predator * const pPredators = swarm.returnPredators();
for (int p = 0; p < nPred; p++){
Predator predator = pPredators[p];
int x = predator.coord.x * Screen::SCREEN_WIDTH / systemSize;
int y = predator.coord.y * Screen::SCREEN_HEIGHT / systemSize;
//store.printCoord(x,y);
screen.setPixel(x, y, 0, 0, 0);
}
screen.update();
if (i >= iterations - last){
swarm.cudaBackCopy();
store.orientationParam += swarm.calcOrderparam();
}
if (screen.processEvents() == false){
break;
}
if (i%10000 == 0){
for (int p = 0; p < particles; p++){
Particle particle = pParticles[p];
store.eta[p] = particle.eta;
store.print(p);
}
store.endl();
}
if (i%wait == 0) swarm.initAttack();
}
screen.close();
/*if (cudaDeviceSynchronize() != cudaSuccess)
cout << "Device synchronisation failed \n";
swarm.cudaUniteIdBackCopy();
swarm.grouping();
c = swarm.findgroups();
cout << "number of independent groups are " << c << "\n";
gsd = new int[c];
swarm.calcgsd(gsd);
for (int i = 0; i < c; i++){
store.printGroupSize(gsd[i]);
}
store.endl();*/
}
/*store.endl();
store.orientationParam = store.orientationParam / realisations / last;
//cout << store.orientationParam << "\n";
store.print(eta);
store.endl();*/
}
time.stop();
timeElapsed = time.printTime();
store.printTime(timeElapsed);
store.fileClose();
//delete []gsd;
return 0;
}