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

C++ TimeStamp类代码示例

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

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



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

示例1: UpdateBias

static ImageHost::Bias
UpdateBias(const TimeStamp& aCompositionTime,
           const TimeStamp& aCompositedImageTime,
           const TimeStamp& aNextImageTime, // may be null
           ImageHost::Bias aBias)
{
  if (aCompositedImageTime.IsNull()) {
    return ImageHost::BIAS_NONE;
  }
  TimeDuration threshold = TimeDuration::FromMilliseconds(1.0);
  if (aCompositionTime - aCompositedImageTime < threshold &&
      aCompositionTime - aCompositedImageTime > -threshold) {
    // The chosen frame's time is very close to the composition time (probably
    // just before the current composition time, but due to previously set
    // negative bias, it could be just after the current composition time too).
    // If the inter-frame time is almost exactly equal to (a multiple of)
    // the inter-composition time, then we're in a dangerous situation because
    // jitter might cause frames to fall one side or the other of the
    // composition times, causing many frames to be skipped or duplicated.
    // Try to prevent that by adding a negative bias to the frame times during
    // the next composite; that should ensure the next frame's time is treated
    // as falling just before a composite time.
    return ImageHost::BIAS_NEGATIVE;
  }
  if (!aNextImageTime.IsNull() &&
      aNextImageTime - aCompositionTime < threshold &&
      aNextImageTime - aCompositionTime > -threshold) {
    // The next frame's time is very close to our composition time (probably
    // just after the current composition time, but due to previously set
    // positive bias, it could be just before the current composition time too).
    // We're in a dangerous situation because jitter might cause frames to
    // fall one side or the other of the composition times, causing many frames
    // to be skipped or duplicated.
    // Try to prevent that by adding a negative bias to the frame times during
    // the next composite; that should ensure the next frame's time is treated
    // as falling just before a composite time.
    return ImageHost::BIAS_POSITIVE;
  }
  return ImageHost::BIAS_NONE;
}
开发者ID:ollie314,项目名称:gecko-dev,代码行数:40,代码来源:ImageHost.cpp


示例2: main

int main()
{
  TimeStamp start;
  TimeStamp newTime;
  TimeStamp dt;
  start.now();
  while (1) {
    newTime.now();
    dt=newTime-start;
    std::cout << dt.getSec() << "sec " << dt.getUSec() << "usec\n";
    if (dt.getSec()>3) return 0;
  }
  return 1;
}
开发者ID:BackupTheBerlios,项目名称:dope,代码行数:14,代码来源:test-timestamp.cpp


示例3: StartTrace

bool SybCTnewDAImpl::CheckCloseOpenedConnections(long lTimeout)
{
	StartTrace(SybCTnewDAImpl.CheckCloseOpenedConnections);
	bool bRet = false;
	Anything anyTimeStamp(coast::storage::Global());
	TimeStamp aStamp;
	aStamp -= lTimeout;
	Trace("current timeout " << lTimeout << "s, resulting time [" << aStamp.AsString() << "]");
	LockUnlockEntry me(fgStructureMutex);
	if ( fgInitialized ) {
		TraceAny(fgListOfSybCT, "current list of connections");
		if ( fgListOfSybCT.LookupPath(anyTimeStamp, "Open") && anyTimeStamp.GetSize() ) {
			SybCTnewDA *pSyb = NULL;
			long lTS = 0L;
			// if we still have open connections and the last access is older than lTimeout seconds
			while ( anyTimeStamp.GetSize() && ( aStamp > TimeStamp(anyTimeStamp.SlotName(lTS)) ) ) {
				Anything anyTS(coast::storage::Global());
				anyTS = anyTimeStamp[lTS];
				TraceAny(anyTS, "stamp of connections to close [" << anyTimeStamp.SlotName(0L) << "]");
				while ( anyTS.GetSize() ) {
					pSyb = SafeCast(anyTS[0L][0L].AsIFAObject(), SybCTnewDA);
					anyTS.Remove(0L);
					if ( pSyb != NULL ) {
						Trace("closing timeouted connection");
						if ( pSyb->Close() ) {
							bRet = true;
						}
					} else {
						SYSWARNING("Sybase connection with address " << (long)pSyb << " not valid anymore!");
					}
					fgListOfSybCT["Unused"].Append((IFAObject *)pSyb);
				}
				anyTimeStamp.Remove(lTS);
			}
		}
	} else {
		SYSERROR("SybCTnewDAImpl not initialized!");
	}
	return bRet;
}
开发者ID:chenbk85,项目名称:CuteTestForCoastTest,代码行数:40,代码来源:SybCTnewDAImpl.cpp


示例4: getKeyValueConfiguration

    coredata::dmcp::ModuleExitCodeMessage::ModuleExitCode Vehicle::body() {
        stringstream sstrConfiguration;
        getKeyValueConfiguration().writeTo(sstrConfiguration);

        // Use libodsimulation's odsimirus implementation.
        string config = sstrConfiguration.str();
        vehiclecontext::model::SimplifiedBicycleModel simplifiedBicycleModel(config);
        simplifiedBicycleModel.setup();

        // Use the most recent EgoState available.
        KeyValueDataStore &kvs = getKeyValueDataStore();

        TimeStamp previousTime;

        while (getModuleStateAndWaitForRemainingTimeInTimeslice() == coredata::dmcp::ModuleStateMessage::RUNNING) {
            // Get current VehicleControl.
            Container c = kvs.get(Container::VEHICLECONTROL);
            automotive::VehicleControl vc = c.getData<automotive::VehicleControl>();

            TimeStamp currentTime;
            const double timeStep = (currentTime.toMicroseconds() - previousTime.toMicroseconds()) / (1000.0 * 1000.0);

            // Calculate result and propagate it.
            vector<Container> toBeSent = simplifiedBicycleModel.calculate(vc, timeStep);
            if (toBeSent.size() > 0) {
                vector<Container>::iterator it = toBeSent.begin();
                while(it != toBeSent.end()) {
                    getConference().send(*it);
                    it++;
                    Thread::usleepFor(50);
                }
            }

            previousTime = currentTime;
        }

        simplifiedBicycleModel.tearDown();

        return coredata::dmcp::ModuleExitCodeMessage::OKAY;
    }
开发者ID:TacoVox,项目名称:OpenDaVINCI,代码行数:40,代码来源:Vehicle.cpp


示例5: CheckDataLoss

/*
 * Check for data loss.
 * TODO(simon): move to the ola server
 */
bool DmxMonitor::CheckDataLoss() {
  if (m_last_data.IsSet()) {
    TimeStamp now;
    Clock clock;
    clock.CurrentTime(&now);
    TimeInterval diff = now - m_last_data;
    if (diff > TimeInterval(2, 5000000)) {
      // loss of data
      DrawDataLossWindow();
    }
  }
  return true;
}
开发者ID:creising,项目名称:ola,代码行数:17,代码来源:ola-dmxmonitor.cpp


示例6: WriteLogToFile

void CWriteLogClass::WriteLogToFile(const char* filename,const char* module,const char* info,const int status)
{
	TimeStamp ts;
	string mlog = ts.getTimeString(2).c_str() ;
	mlog += module;
	mlog += ",";
	mlog += info;
	mlog += ",";
	if (!status)
	{
		mlog += "³É¹¦";
	}
	else
	{
		mlog += "ʧ°Ü";
	}
	mlog += "\n";
	cout << mlog << endl;
	FILE * fp = fopen(filename,"a+");
	fwrite(mlog.c_str(),1,mlog.size(),fp);
	fclose(fp);
}
开发者ID:codeworkscn,项目名称:learn-cpp,代码行数:22,代码来源:WriteLogClass.cpp


示例7: wait

        void ClientModule::wait() {
            // Update liveliness.
            m_cycleCounter++;
            TimeStamp current;
            const float FREQ = getFrequency();
            const long TIME_CONSUMPTION_OF_CURRENT_SLICE = (current.toMicroseconds() - m_lastCycle.toMicroseconds()) - m_lastWaitTime;
            m_lastCycle = current;
            const long ONE_SECOND_IN_MICROSECONDS = 1000 * 1000 * 1;
            const long NOMINAL_DURATION_OF_ONE_SLICE = static_cast<long>((1.0f/FREQ) * ONE_SECOND_IN_MICROSECONDS);
            const long WAITING_TIME_OF_CURRENT_SLICE = NOMINAL_DURATION_OF_ONE_SLICE - TIME_CONSUMPTION_OF_CURRENT_SLICE;

            // Inform supercomponent about statistical runtime data.
            bool sendStatistics = false;
            if (FREQ < 1) {
                sendStatistics = true;
            }
            else {
				const int32_t CYCLES_PER_SECOND = static_cast<int32_t>(fabs(floor(FREQ + 0.5)));
                if ( (m_cycleCounter % CYCLES_PER_SECOND) == 0 ) {
                    sendStatistics = true;
                    m_cycleCounter = 0;
                }
            }

            if (sendStatistics) {
                RuntimeStatistic rts;
                rts.setSliceConsumption((float)TIME_CONSUMPTION_OF_CURRENT_SLICE/(float)NOMINAL_DURATION_OF_ONE_SLICE);
                m_dmcpClient->sendStatistics(rts);
            }

            if (WAITING_TIME_OF_CURRENT_SLICE > 0) {
                m_lastWaitTime = WAITING_TIME_OF_CURRENT_SLICE;
                Thread::usleep(WAITING_TIME_OF_CURRENT_SLICE);
            }
            else {
                m_lastWaitTime = 0;
            }
        }
开发者ID:Duxiao777,项目名称:2013-mini-smart-vehicles,代码行数:38,代码来源:ClientModule.cpp


示例8: while

void VectorPerformanceThread::run()
{
    TimeStamp timeStamp;
    TimeStamp timeStampLast;
    timeStampLast.getCurrent();
    int nSinceLastReport = 0;
    while(true) {
        if(delay>0.0) epicsThreadSleep(delay);
        {
            Lock lock(mutex);
            if(isDestroyed) {
                runReturned = true;
                return;
            }
        }
        timeStamp.getCurrent();
        double diff = TimeStamp::diff(timeStamp,timeStampLast);
        if(diff>=1.0) {
            cout << "thread" << threadNumber;
            cout << " value " << value;
            cout << " time " << diff;
            double iterations = nSinceLastReport;
            iterations /= diff;
            cout << " iterations/sec " << iterations;
            double elementSize = size;
            double elementsPerSecond = elementSize*nSinceLastReport;
            elementsPerSecond /= diff;
            elementsPerSecond /= 1e6;
            cout << " elements/sec " << elementsPerSecond << "million" << endl;
            cout.flush();
            timeStampLast = timeStamp;
            nSinceLastReport = 0;
        }
        ++nSinceLastReport;
        ++value;
        for(size_t i=0; i<size; ++i) vector[i] = value;
    }
}
开发者ID:dhickin,项目名称:exampleCPP,代码行数:38,代码来源:vectorPerformanceMain.cpp


示例9: MOZ_LOG

// aID is a sub-identifier (in particular a specific MediaStramTrack)
void AsyncLatencyLogger::WriteLog(LatencyLogIndex aIndex, uint64_t aID, int64_t aValue,
                                  TimeStamp aTimeStamp)
{
  if (aTimeStamp.IsNull()) {
    MOZ_LOG(GetLatencyLog(), LogLevel::Debug,
      ("Latency: %s,%" PRIu64 ",%" PRId64 ",%" PRId64,
       LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue));
  } else {
    MOZ_LOG(GetLatencyLog(), LogLevel::Debug,
      ("Latency: %s,%" PRIu64 ",%" PRId64 ",%" PRId64 ",%" PRId64,
       LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue,
       static_cast<int64_t>((aTimeStamp - gAsyncLogger->mStart).ToMilliseconds())));
  }
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:15,代码来源:Latency.cpp


示例10: return

/*PLONK_INLINE_LOW*/ bool TimeStamp::operator>= (TimeStamp const& other) const throw()
{
    plonk_assert (fractionIsValid (this->fraction));
    plonk_assert (fractionIsValid (other.fraction));
    
    if (this->isInfinite())
    {
        if (other.isInfinite())
            return false;
        else
            return true;
    }
    else return ((time > other.time) || ((time == other.time) && (fraction >= other.fraction)));
}
开发者ID:0x4d52,项目名称:pl-nk,代码行数:14,代码来源:plonk_TimeStamp.cpp


示例11: PR_LOG

// aID is a sub-identifier (in particular a specific MediaStramTrack)
void AsyncLatencyLogger::WriteLog(LatencyLogIndex aIndex, uint64_t aID, int64_t aValue,
                                  TimeStamp aTimeStamp)
{
  if (aTimeStamp.IsNull()) {
    PR_LOG(GetLatencyLog(), PR_LOG_DEBUG,
      ("Latency: %s,%llu,%lld,%lld",
       LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue));
  } else {
    PR_LOG(GetLatencyLog(), PR_LOG_DEBUG,
      ("Latency: %s,%llu,%lld,%lld,%lld",
       LatencyLogIndex2Strings[aIndex], aID, GetTimeStamp(), aValue,
       static_cast<int64_t>((aTimeStamp - gAsyncLogger->mStart).ToMilliseconds())));
  }
}
开发者ID:ConradIrwin,项目名称:gecko-dev,代码行数:15,代码来源:Latency.cpp


示例12: preDraw

void Canvas::Draw()
{
	if (_StyleModules.empty())
		return;
	preDraw();
	TimeStamp *timestamp = TimeStamp::instance();

	for (unsigned int i = 0; i < _StyleModules.size(); ++i) {
		_current_sm = _StyleModules[i];

		if (i < _Layers.size() && _Layers[i])
			delete _Layers[i];

		_Layers[i] = _StyleModules[i]->execute();
		if (!_Layers[i])
			continue;

		stroke_count += _Layers[i]->strokes_size();

		timestamp->increment();
	}
	postDraw();
}
开发者ID:244xiao,项目名称:blender,代码行数:23,代码来源:Canvas.cpp


示例13: dateTimeToDB

LightSpeed::StringA dateTimeToDB(const LightSpeed::JSON::INode &nd) {
	using namespace LightSpeed;
	if (nd.getType() == JSON::ndString) {
		ConstStrA str = nd.getStringUtf8();
		TextParser<char, SmallAlloc<256> > parser;
		if (parser(" NOW ",str)) {
			TimeStamp st = TimeStamp::now();
			return st.formatTime(dbDateTimeFormat);
		} else if (parser(" NOW %[-+]f1 ",str)) {
			float ofs = parser[1];
			TimeStamp st = TimeStamp::now() + TimeStamp(ofs);
			return st.formatTime(dbDateTimeFormat);
		}
		return nd.getStringUtf8();
	} else if (nd.getType() == JSON::ndFloat || nd.getType() == JSON::ndInt) {
		TimeStamp st(nd.getFloat());
		return st.formatTime(dbDateTimeFormat);
	} else if (nd.getType() == JSON::ndNull) {
		return "0000-00-00 00:00:00";
	}
	return "0000-00-00 00:00:00";

}
开发者ID:ondra-novak,项目名称:jsonrpcserver,代码行数:23,代码来源:db.cpp


示例14: timeplot

/*
 * Makes n plots and times them.
 * Plot number k is called sink.
 * It is a plot of sin(kx) vs. x
 */
void timeplot(int n){
	double x[n*10];
	double y[n*10];
	StatVector stats(n);
	TimeStamp clk;
	for(int i=1; i <= n; i++){
		printf("\r%d", i);
		fflush(stdout);
		char name[30];
		sprintf(name, "sin%d", i);
		for(int j=0; j < n*10; j++){
			x[j] = 2*PI*i*j/(n*10.0);
			y[j] = sin(x[j]*i);
		}
		clk.tic();
		makeplot(x, y, 10*n, name);
		double cycles = clk.toc();
		stats.insert(cycles);
	}
	char banner[200];
	sprintf(banner, "cycle stats for %d plots", n);
	stats.print(banner);
	system("rm FIGS/sin*.pdf");
}
开发者ID:divakarvi,项目名称:Book-SPCA,代码行数:29,代码来源:test_pyplot.cpp


示例15: qDebug

void DialogEditTime::on_buttonBox_accepted()
{
    // workaround for missing leading zero bug: prepend a "0", if it is missing
    QString tStr = ui->lineEdit->text();
    QStringList helper = tStr.split(":");
    if(helper.first().length() == 1){
        tStr.prepend("0");
    }
    // end of workaround

    QTime t = QTime::fromString(tStr);
    qDebug() << "zeit: " << t.toString();

	TimeStamp* ts =0;

	if(myRun){// ignore runns with Nullpointer
		if(myTimeType == TT_START){
			if(myRun->getStartTimeID() == 0){ // if no TS exists, create a new one
				ts = new TimeStamp(0, t, TimeStamp::E);
				MainWindow::competition()->addTimeStamp(ts);
				ts->setRunID(myRun->getID());
				myRun->setStartTimeID(ts->getID());
			}else{
				ts = MainWindow::competition()->getTimeStamp(myRun->getStartTimeID());
			}
        }else{ // goal
			if(myRun->getGoalTimeID() == 0){ // if no TS exists, create a new one
				ts = new TimeStamp(0, t, TimeStamp::E);
				MainWindow::competition()->addTimeStamp(ts);
				ts->setRunID(myRun->getID());
				myRun->setGoalTimeID(ts->getID());
			}else{
				ts = MainWindow::competition()->getTimeStamp(myRun->getGoalTimeID());
			}
		}

		// if new time != old time
		// compare strings, because of sub-0.01s differences, which should be ignored
		if(MainWindow::convertTimeToString(ts->getTime()) != MainWindow::convertTimeToString(t)){
			ts->setTime(t);
			ts->setSource(TimeStamp::E);
			emit timeEdited(myRun);
		}
	}
	hide();
}
开发者ID:GerZan,项目名称:kiboko-manager,代码行数:46,代码来源:dialogedittime.cpp


示例16: time

double time(double *a, double *b, int n, enum sumcopy_enum flag){
	const int count = 10;
	StatVector stats(count);
	TimeStamp clk;
	
	double bytes = 8.0*n;
	for(int i=0; i < count; i++){
		clk.tic();
		
		switch(flag){
		case SUM:
			sum(a, n);
			break;
		case SUMSTR:
			sumstride(a, n, STR);
			break;
		case SUMCONSTSTR:
			sumconststride(a, n);
			break;
		case COPY:
			copy(a, b, n);
			break;
		case COPYCONSTSTR:
			copyconststride(a, b, n);
			break;
		}
		double cycles = clk.toc();
		stats.insert(cycles);
	}

	if(flag == COPY || flag == COPYCONSTSTR)
		bytes *= 2;
	if (!(flag == SUM || flag == COPY))
		bytes /= STR;
	return bytes/stats.median();
}
开发者ID:qzmfranklin,项目名称:salon,代码行数:36,代码来源:time_sumcopy.cpp


示例17: lock

void VideoFrameContainer::SetCurrentFrame(const gfxIntSize& aIntrinsicSize,
                                          Image* aImage,
                                          TimeStamp aTargetTime)
{
  MutexAutoLock lock(mMutex);

  if (aIntrinsicSize != mIntrinsicSize) {
    mIntrinsicSize = aIntrinsicSize;
    mIntrinsicSizeChanged = true;
  }

  gfxIntSize oldFrameSize = mImageContainer->GetCurrentSize();
  TimeStamp lastPaintTime = mImageContainer->GetPaintTime();
  if (!lastPaintTime.IsNull() && !mPaintTarget.IsNull()) {
    mPaintDelay = lastPaintTime - mPaintTarget;
  }

  // When using the OMX decoder, destruction of the current image can indirectly
  //  block on main thread I/O. If we let this happen while holding onto
  //  |mImageContainer|'s lock, then when the main thread then tries to
  //  composite it can then block on |mImageContainer|'s lock, causing a
  //  deadlock. We use this hack to defer the destruction of the current image
  //  until it is safe.
  nsRefPtr<Image> kungFuDeathGrip;
  kungFuDeathGrip = mImageContainer->LockCurrentImage();
  mImageContainer->UnlockCurrentImage();

  mImageContainer->SetCurrentImage(aImage);
  gfxIntSize newFrameSize = mImageContainer->GetCurrentSize();
  if (oldFrameSize != newFrameSize) {
    mImageSizeChanged = true;
    mNeedInvalidation = true;
  }

  mPaintTarget = aTargetTime;
}
开发者ID:BitVapor,项目名称:Pale-Moon,代码行数:36,代码来源:VideoFrameContainer.cpp


示例18: TimeToFileTime

bool TimeToFileTime(TimeStamp& time, LPFILETIME pFileTime)
{
	SYSTEMTIME sysTime;
	time.getTime(sysTime);

	// convert system time to local file time
	FILETIME localTime;
	if (!SystemTimeToFileTime((LPSYSTEMTIME)&sysTime, &localTime))
		return false;

	// convert local file time to UTC file time
	if (!LocalFileTimeToFileTime(&localTime, pFileTime))
		return false;

	return true;
}
开发者ID:princetoad,项目名称:acdx,代码行数:16,代码来源:TextFile.cpp


示例19: mozilla_sampler_responsiveness

void mozilla_sampler_responsiveness(const TimeStamp& aTime)
{
  if (!sLastTracerEvent.IsNull()) {
    if (sResponsivenessLoc == 100) {
      for(size_t i = 0; i < 100-1; i++) {
        sResponsivenessTimes[i] = sResponsivenessTimes[i+1];
      }
      sResponsivenessLoc--;
    }
    TimeDuration delta = aTime - sLastTracerEvent;
    sResponsivenessTimes[sResponsivenessLoc++] = delta.ToMilliseconds();
  }
  sCurrentEventGeneration++;

  sLastTracerEvent = aTime;
}
开发者ID:,项目名称:,代码行数:16,代码来源:


示例20:

Nullable<TimeDuration> DocumentTimeline::ToTimelineTime(
    const TimeStamp& aTimeStamp) const {
  Nullable<TimeDuration> result;  // Initializes to null
  if (aTimeStamp.IsNull()) {
    return result;
  }

  nsDOMNavigationTiming* timing = mDocument->GetNavigationTiming();
  if (MOZ_UNLIKELY(!timing)) {
    return result;
  }

  result.SetValue(aTimeStamp - timing->GetNavigationStartTimeStamp() -
                  mOriginTime);
  return result;
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:16,代码来源:DocumentTimeline.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ TimeStat类代码示例发布时间:2022-05-31
下一篇:
C++ TimeSpan类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap