本文整理汇总了C++中TimeStamp类的典型用法代码示例。如果您正苦于以下问题:C++ TimeStamp类的具体用法?C++ TimeStamp怎么用?C++ TimeStamp使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimeStamp类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例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())));
}
}
示例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)));
}
示例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())));
}
}
示例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();
}
示例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";
}
示例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");
}
示例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();
}