static void TimeConstruction(int depth) { long tStart, tFinish; int iNumIters = NumIters(depth); Node tempTree; printf("Creating %d trees of depth %d\n", iNumIters, depth); tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { # ifndef GC tempTree = new Node0(); # else tempTree = new GC_NEW(Node0) Node0(); # endif Populate(depth, tempTree); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); printf("\tTop down construction took %d msec\n", elapsedTime(tFinish - tStart)); tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { tempTree = MakeTree(depth); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); printf("\tBottom up construction took %d msec\n", elapsedTime(tFinish - tStart)); }
void KernelSourceParser::operationProgress() { QMutexLocker lock(&_progressMutex); float percent = _bytesRead / (float) (_bytesTotal > 0 ? _bytesTotal : 1); int remaining = -1; // Avoid too noisy timer updates if (percent > 0) { remaining = _durationLastFileFinished / percent * (1.0 - percent); remaining = (remaining - (_duration - _durationLastFileFinished)) / 1000; } QString remStr = remaining > 0 ? QString("%1:%2").arg(remaining / 60).arg(remaining % 60, 2, 10, QChar('0')) : QString("??"); QString fileName = _currentFile; QString s = QString("\rParsing file %1/%2 (%3%), %4 elapsed, %5 remaining%7: %6") .arg(_filesIndex) .arg(_fileNames.size()) .arg((int)(percent * 100)) .arg(elapsedTime()) .arg(remStr) .arg(fileName); // Show no. of errors if (BugReport::log() && BugReport::log()->entries()) s = s.arg(QString(", %1 errors so far").arg(BugReport::log()->entries())); else s = s.arg(QString()); shellOut(s, false); }
int prTempoClock_New(struct VMGlobals *g, int numArgsPushed) { PyrSlot *a = g->sp - 3; PyrSlot *b = g->sp - 2; PyrSlot *c = g->sp - 1; PyrSlot *d = g->sp; double tempo; int err = slotDoubleVal(b, &tempo); if (err) tempo = 1.; if (tempo <= 0.) { error("invalid tempo %g\n", tempo); SetPtr(slotRawObject(a)->slots+1, NULL); return errFailed; } double beats; err = slotDoubleVal(c, &beats); if (err) beats = 0.; double seconds; err = slotDoubleVal(d, &seconds); if (err) seconds = elapsedTime(); TempoClock* clock = new TempoClock(g, slotRawObject(a), tempo, beats, seconds); SetPtr(slotRawObject(a)->slots+1, clock); return errNone; }
WrapImplSoftware::~WrapImplSoftware() { printf("LazyWrapTime= \t%ld\n", elapsedTime()); printf("cleaning up wrapimplsoftware\n"); delete _table; Debug("done deleting table.\n"); }
main(int argc,char** argv) { double seconds; double dt; fprintf(stderr,"#######################################\n"); fprintf(stderr," You can specify \"dt\" and \"runtime\".\n"); fprintf(stderr,"#######################################\n"); if (argc > 1) { dt=atoi(argv[1]); if (argc > 2) seconds=atoi(argv[2]); else seconds=20; } else { dt=2; /* default dt = 2 */ seconds=20; /* default sec = 20 */ } fprintf(stderr,"\ndt : %f\t runtime : %f\n\n",dt,seconds); TC_UDP_TX_I_inputdt(dt); startTimer(); for(; elapsedTime()<seconds;) /* for (;;)*/ TC_UDP_TX(); STOP_PERF_GRAPH(); GET_PERF_GRAPH(seconds); }
void PresentationAudioWidget::slotTimeUpdaterTimeout() { if (d->mediaObject->error() != QMediaPlayer::NoError) { slotError(); return; } qint64 current = d->mediaObject->position(); int hours = (int)(current / (qint64)(60 * 60 * 1000)); int mins = (int)((current / (qint64)(60 * 1000)) - (qint64)(hours * 60)); int secs = (int)((current / (qint64)1000) - (qint64)(hours * 60 + mins * 60)); QTime elapsedTime(hours, mins, secs); if (d->isZeroTime && d->mediaObject->duration() > 0) { d->isZeroTime = false; qint64 total = d->mediaObject->duration(); hours = (int)(total / (qint64)(60 * 60 * 1000)); mins = (int)((total / (qint64)(60 * 1000)) - (qint64)(hours * 60)); secs = (int)((total / (qint64)1000) - (qint64)(hours * 60 + mins * 60)); QTime totalTime(hours, mins, secs); m_totalTimeLabel->setText(totalTime.toString(QString::fromLatin1("H:mm:ss"))); } m_elapsedTimeLabel->setText(elapsedTime.toString(QString::fromLatin1("H:mm:ss"))); }
//! Post progress message //! //! @param progress - How many bytes of progress since last call //! @param message - Message to post, May be NULL to indicate no change. //! USBDM_ErrorCode ProgressTimer::progress(int progress, const char *_message) { USBDM_ErrorCode rc = PROGRAMMING_RC_OK; if (_message != NULL) { message = _message; } bytesDone += progress; int percent = 0; if (maximumBytes > 0) { percent = ((100UL*bytesDone)/maximumBytes); } double kBytesPerSec = 0; double elapsed = elapsedTime(); if ((elapsed > 0) && (bytesDone > 0)) { kBytesPerSec = bytesDone/(1024*elapsed); } if (message == NULL) { message = ""; } char messageBuffer[200]; snprintf(messageBuffer, sizeof(messageBuffer), "%s (%2.2f kBytes/sec)", message, kBytesPerSec); if ((progressCallBack != NULL) && (progress != 0)) { if (bytesDone>0) { rc = progressCallBack(PROGRAMMING_RC_OK, percent, messageBuffer); } else { rc = progressCallBack(PROGRAMMING_RC_OK, percent, message); } } // print("ProgressTimer::Timer::progress() - \'%s\', Time = %3.2f, Progress done = %d(+%d) (%d%%)\n", // messageBuffer, elapsed, bytesDone, progress, percent); return rc; }
/// /// \brief ParticleSystem::buildGLBuffers /// Build vertices data buffers to be passed to the shader /// This includes : /// Relative positions /// For now, it's all (0,0,0) /// Consider it to be an offset for particle drawing, as true positions are calculated /// in the shader; /// Velocities /// Ages /// void ParticleSystem::buildGLBuffers(){ if(gl_positions != NULL) delete gl_positions; gl_positions = new float[m_TabParticle.size()*3]; if(gl_velocities != NULL) delete gl_velocities; gl_velocities = new float[m_TabParticle.size()*3]; if(gl_ages != NULL) delete gl_ages; gl_ages = new float[m_TabParticle.size()]; for(unsigned int i=0; i<m_TabParticle.size(); i++){ Particle* p = m_TabParticle[i]; gl_positions[3*i] = p->position.x; gl_positions[3*i+1] = p->position.y; gl_positions[3*i+2] = p->position.z; gl_velocities[3*i] = p->velocity.x; gl_velocities[3*i+1] = p->velocity.y; gl_velocities[3*i+2] = p->velocity.z; gl_ages[i] = elapsedTime(p->startTime, Clock::now()) / 1000.0f; //std::cout<<velocities[3*i]<<" "<<velocities[3*i+1]<<" "<<velocities[3*i+2]<<std::endl; //std::cout << i << " : " << ages[i] << std::endl; } }
double downloadSpeed(int time, int startTime, double bytes) { int mtime = elapsedTime(time, startTime); double result = bytes/mtime; return result; }
void PlaybackWidget::slotTimeUpdaterTimeout() { if ( m_mediaObject->state() == Phonon::ErrorState ) { slotError(); return; } long int current = m_mediaObject->currentTime(); int hours = (int)(current / (long int)( 60 * 60 * 1000 )); int mins = (int)((current / (long int)( 60 * 1000 )) - (long int)(hours * 60)); int secs = (int)((current / (long int)1000) - (long int)(hours * 60 + mins * 60)); QTime elapsedTime(hours, mins, secs); if ( m_isZeroTime ) { m_isZeroTime = false; long int total = m_mediaObject->totalTime(); hours = (int)(total / (long int)( 60 * 60 * 1000 )); mins = (int)((total / (long int)( 60 * 1000 )) - (long int)(hours * 60)); secs = (int)((total / (long int)1000) - (long int)(hours * 60 + mins * 60)); QTime totalTime(hours, mins, secs); m_totalTimeLabel->setText(totalTime.toString("H:mm:ss")); } m_elapsedTimeLabel->setText(elapsedTime.toString("H:mm:ss")); }
bool AndroidAnimation::checkIterationsAndProgress(double time, float* finalProgress) { double progress = elapsedTime(time); double dur = m_duration; if (m_iterationCount > 0) dur *= m_iterationCount; if (m_duration <= 0) return false; // If not infinite, return false if we are done if (m_iterationCount > 0 && progress > dur) { *finalProgress = 1.0; if (!m_hasFinished) { // first time past duration, continue with progress 1.0 so the // element's final position lines up with it's last keyframe m_hasFinished = true; return true; } return false; } double fractionalTime = progress / m_duration; int integralTime = static_cast<int>(fractionalTime); fractionalTime -= integralTime; if ((m_direction == Animation::AnimationDirectionAlternate) && (integralTime & 1)) fractionalTime = 1 - fractionalTime; *finalProgress = fractionalTime; return true; }
// Show some progress information void KernelSymbolWriter::operationProgress() { QString s("\rWriting symbols"); if (!_to->isSequential()) s += QString(" (%1 written)").arg(bytesToString(_to->pos())); s += ", " + elapsedTime() + " elapsed"; shellOut(s, false); }
int main (int argc, char ** argv) { int max = MAX_NOEUDS / SCALE + 2; int capa = 50; int ** tab = (int**) malloc (max * sizeof(int*)); int i; for (i=SCALE; i<=MAX_NOEUDS; i+=SCALE) { int j = (i/SCALE) - 1; tab[j] = (int *) malloc(2*sizeof(int)); tab[j][0] = i; tab[j][1] = (int) ceil (1. * i * RATIO); } for (i=SCALE; i<=MAX_NOEUDS; i+=SCALE) { int j = (i/SCALE) - 1; stat_t s = elapsedTime(tab[j][0],tab[j][1],capa,100); printf("%d %d %lf %lf %lf \n",tab[j][0],tab[j][1],s._st1*1000,s._st2*1000,s._st3*1000); } /*Graph * mcEK = allocMatGraph(5); Graph * lcEK = allocListGraph(5); randFill(mcEK,15,5,1,lcEK); Graph * mcDinic = copyGraph(mcEK); Graph * lcDinic = copyGraph(lcEK); Graph * mdEK = copyGraph(mcEK); Graph * mfEK = allocGraph(mcEK); Graph * mdDinic = copyGraph(mcDinic); Graph * mfDinic = allocGraph(mcDinic); Graph * lfEK = allocGraph(lcEK); Graph * ldEK = copyGraph(lcEK); Graph * lfDinic = allocGraph(lcDinic); int mEK = algoEdmondKarp (lcEK,ldEK,lfEK,0,1); printf("EK : Matrix = %d\n", mEK); int mDinic = algoDinic (mcDinic,mfDinic,0,1); printf("Dinic : Matrix = %d\n", mDinic); int lDinic = algoDinic (lcDinic,lfDinic,0,1); printf("Dinic : List = %d\n", lDinic); int lEK = algoEdmondKarp (mcEK,mdEK,mfEK,0,1); printf("EK : List = %d\n", lEK); */ for (i=0; i<max; free(*(tab+i++))); free(tab); argc++;argv--;/* Wall ... */ return 0; }
void GLWidget::clientDraw() { // drawMesh(); drawTetra(); const float t = (float)elapsedTime(); m_mesh->setAlpha(t/290.f); m_ray->setAlpha(t/230.f); // qDebug()<<"drawn in "<<deltaTime(); // internalTimer()->start(); }
/// /// \brief ParticleSystem::deleteDeadParticles /// Delete particles that are supposed to be dead : /// = If a particle is too old and doesn't fit Meryn Trant's needs /// void ParticleSystem::deleteDeadParticles(){ for(unsigned int i=0; i<m_TabParticle.size(); i++){ Particle* p = m_TabParticle[i]; if(p != NULL && elapsedTime(p->startTime, t_currentTime) > m_maxTimeAlive){ m_TabParticle.erase(m_TabParticle.begin()+i); m_TabParticle.shrink_to_fit(); } } }
void TextTestResult::printHeader (std::ostream &stream) { if (wasSuccessful ()) std::cout << "OK (" << runTests () << " tests and " << testSuccesses() << " assertions in " << elapsedTime() << " ms)" << std::endl; else std::cout << std::endl << "!!!FAILURES!!!" << std::endl << "Test Results:" << std::endl << "Run: " << runTests () << " Failures: " << testFailures () << " Errors: " << testErrors () << std::endl << "(" << testSuccesses() << " assertions ran successfully in " << elapsedTime() << " ms)" << std::endl; }
inline void PyrGC::beginPause() { checkStackScans = mStackScans; checkFlips = mFlips; checkScans = mScans; checkNumToScan = mNumToScan; checkPartialScans = mNumPartialScans; checkSlotsScanned = mSlotsScanned; pauseBeginTime = elapsedTime(); }
StopWatch::~StopWatch() { nsecs_t elapsed = elapsedTime(); const int n = mNumLaps; LOGD("StopWatch %s (us): %lld ", mName, ns2us(elapsed)); for (int i=0 ; i<n ; i++) { const nsecs_t soFar = mLaps[i].soFar; const nsecs_t thisLap = mLaps[i].thisLap; LOGD(" [%d: %lld, %lld]", i, ns2us(soFar), ns2us(thisLap)); } }
void GeigerCounter::device_loop(Command command){ if (elapsedTime(lastUpdateTime) < updateIntervalInMillis) { return; } float countsPerMinute = (float)count / (float)updateIntervalInMillis/60000; // Convert from cpm to µSv/h with the pre-defined coefficient float microSievertPerHour = countsPerMinute * conversionCoefficient; count = 0; envdata::RAD = microSievertPerHour; }
void MemoryMap::operationProgress() { MemoryMapNode* node = _shared->lastNode; const BaseType* nodeType = node ? node->type() : 0; int queueSize = _shared->queue.size(); QChar indicator = '='; if (_prevQueueSize < queueSize) indicator = '+'; else if (_prevQueueSize > queueSize) indicator = '-'; float prob = node ? node->probability() : 1.0; int depth = 0; for (MemoryMapNode* n = node; n; n = n->parent()) ++depth; Console::out() << right << qSetFieldWidth(5) << elapsedTime() << qSetFieldWidth(0) << " Proc: " << Console::color(ctBold) << qSetFieldWidth(6) << _shared->processed << qSetFieldWidth(0) << Console::color(ctReset) << ", addr: " << qSetFieldWidth(6) << _vmemAddresses.size() << qSetFieldWidth(0) << ", objs: " << qSetFieldWidth(6) << _vmemMap.size() << qSetFieldWidth(0) << ", vmem: " << qSetFieldWidth(6) << _vmemMap.nodeCount() << qSetFieldWidth(0) << ", pmem: " << qSetFieldWidth(6) << _pmemMap.nodeCount() << qSetFieldWidth(0) << ", q: " << qSetFieldWidth(5) << queueSize << qSetFieldWidth(0) << " " << indicator << ", d: " << qSetFieldWidth(2) << depth << qSetFieldWidth(0) << ", p: " << qSetRealNumberPrecision(5) << fixed; if (prob < 0.4) Console::out() << Console::color(ctMissed); else if (prob < 0.7) Console::out() << Console::color(ctDeferred); else Console::out() << Console::color(ctMatched); Console::out() << prob << Console::color(ctReset); // << ", min_prob: " << (queueSize ? _shared->queue.smallest()->probability() : 0); if (nodeType) { Console::out() << ", " << Console::prettyNameInColor(nodeType) << " "; if (node->parent()) Console::out() << Console::color(ctMember); else Console::out() << Console::color(ctVariable); Console::out() << node->name() << Console::color(ctReset); } Console::out() << left << endl; _prevQueueSize = queueSize; }
int main(void) { struct time time1,time2,differenceTime; printf("enter time1 (HH:MM:SS) : "); scanf("%d:%d:%d",&time1.hours,&time1.minutes,&time1.seconds); printf("enter time2 (HH:MM:SS) : "); scanf("%d:%d:%d",&time2.hours,&time2.minutes,&time2.seconds); differenceTime=elapsedTime(time1,time2); printf("elapsed time is : \n"); printf("%d:%2d:%2d\n",differenceTime.hours,differenceTime.minutes,differenceTime.seconds); return 0; }
void indri::utility::IndriTimer::printElapsedSeconds( std::ostream& out ) const { UINT64 elapsed = elapsedTime(); const UINT64 million = 1000000; int minutes = int(elapsed / (60 * million)); int seconds = int(elapsed/million - 60*minutes); int microseconds = int(elapsed % million); out << minutes << ":" << std::setw(2) << std::setfill('0') << seconds; }
nsecs_t StopWatch::lap() { nsecs_t elapsed = elapsedTime(); if (mNumLaps >= 8) { elapsed = 0; } else { const int n = mNumLaps; mLaps[n].soFar = elapsed; mLaps[n].thisLap = n ? (elapsed - mLaps[n-1].soFar) : elapsed; mNumLaps = n+1; } return elapsed; }
static void TimeConstruction(int depth) { long tStart, tFinish; int iNumIters = NumIters(depth); Node tempTree; cout << "Creating " << iNumIters << " trees of depth " << depth << endl; tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { # ifndef GC tempTree = new Node0(); # else tempTree = new (GC_NEW(Node0)) Node0(); # endif Populate(depth, tempTree); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); cout << "\tTop down construction took " << elapsedTime(tFinish - tStart) << " msec" << endl; tStart = currentTime(); for (int i = 0; i < iNumIters; ++i) { tempTree = MakeTree(depth); # ifndef GC delete tempTree; # endif tempTree = 0; } tFinish = currentTime(); cout << "\tBottom up construction took " << elapsedTime(tFinish - tStart) << " msec" << endl; }
SC_DLLEXPORT_C bool compileLibrary() { //printf("->compileLibrary\n"); shutdownLibrary(); pthread_mutex_lock (&gLangMutex); gNumCompiledFiles = 0; compiledOK = false; // FIXME: the library config should have been initialized earlier! if (!gLibraryConfig) SC_LanguageConfig::readDefaultLibraryConfig(); compileStartTime = elapsedTime(); totalByteCodes = 0; #ifdef NDEBUG postfl("compiling class library...\n"); #else postfl("compiling class library (debug build)...\n"); #endif bool res = passOne(); if (res) { postfl("\tpass 1 done\n"); if (!compileErrors) { buildDepTree(); traverseFullDepTree(); traverseFullDepTree2(); flushPostBuf(); if (!compileErrors && gShowWarnings) { SymbolTable* symbolTable = gMainVMGlobals->symbolTable; symbolTable->CheckSymbols(); } } pyr_pool_compile->FreeAll(); flushPostBuf(); compileSucceeded(); } else { compiledOK = false; } pthread_mutex_unlock (&gLangMutex); //printf("<-compileLibrary\n"); return compiledOK; }
int main(void) { long tStart, tFinish; std::cout << "Merge_sort of array of " << ARRAY_SIZE << " elements:" << std::endl; std::cout << "\tCreating "; tStart = currentTime(); gc_ptr<int> arr = gc_new<int>(ARRAY_SIZE), res = gc_new<int>(ARRAY_SIZE); for (int i = 0; i < ARRAY_SIZE; i++) { arr[i] = rand() % (ARRAY_SIZE); } tFinish = currentTime(); std::cout << elapsedTime(tFinish - tStart) << " msec" << std::endl; std::cout << "\tSorting "; tStart = currentTime(); merge_sort(res, arr, 0, ARRAY_SIZE - 1); tFinish = currentTime(); std::cout << elapsedTime(tFinish - tStart) << " msec" << std::endl; // for (int i = 0; i < ARRAY_SIZE; i++) // std::cout << res[i] << std::endl; return 0; }
/// /// \brief ParticleSystem::update /// Update timers and manage particles life and death /// void ParticleSystem::update() { t_timeSinceLastFrame = elapsedTime(t_currentTime, std::chrono::steady_clock::now()); t_currentTime = Clock::now(); t_timeSinceLastTrigger = elapsedTime(t_lastTrigger, t_currentTime); //std::cout<<timeSinceLastTrigger<<std::endl; int nb = t_timeSinceLastTrigger / (1000/m_rate); if(nb >= 1) { t_lastTrigger = t_currentTime; //std::cout<<timeSinceLastTrigger<<std::endl; while(nb >= 1){ addParticle(); nb--; } } if(m_maxTimeAlive > 0) deleteDeadParticles(); }
void PerformOSCMessage(int inSize, char *inData, PyrObject *replyObj, int inPortNum) { PyrObject *arrayObj = ConvertOSCMessage(inSize, inData); // call virtual machine to handle message VMGlobals *g = gMainVMGlobals; ++g->sp; SetObject(g->sp, g->process); ++g->sp; SetFloat(g->sp, elapsedTime()); // time ++g->sp; SetObject(g->sp, replyObj); ++g->sp; SetInt(g->sp, inPortNum); ++g->sp; SetObject(g->sp, arrayObj); runInterpreter(g, s_recvoscmsg, 5); }
void XmlResultPrinter::endTest(const Test& test) { auto lastest = tests.top(); auto elapsedTime = lastest->elapsedTime(); collectTime(elapsedTime); std::string result = handlerTestResult(*lastest); builder->addAttributeTo("testcase", "status", result); builder->addAttributeTo("testcase", "time", format(elapsedTime)); builder->addAttributeTo("testcase", "classname", getShortTestcaseName(test.getName())); tests.pop(); }
main(int argc,char** argv){ double seconds; fprintf(stderr,"#######################################\n"); fprintf(stderr," You can specify \"runtime\".\n"); fprintf(stderr,"#######################################\n"); if (argc > 1) seconds=atoi(argv[1]); else seconds=10; startTimer(); for(;elapsedTime()<seconds;) UDP_FLOW(); STOP_PERF_GRAPH(); GET_PERF_GRAPH(seconds); }