本文整理汇总了C++中TimePoint类的典型用法代码示例。如果您正苦于以下问题:C++ TimePoint类的具体用法?C++ TimePoint怎么用?C++ TimePoint使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TimePoint类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: TEST
TEST(EventBaseTest, RunInThread) {
uint32_t numThreads = 50;
uint32_t opsPerThread = 100;
RunInThreadData data(numThreads, opsPerThread);
deque<std::thread> threads;
for (uint32_t i = 0; i < numThreads; ++i) {
threads.emplace_back([i, &data] {
for (int n = 0; n < data.opsPerThread; ++n) {
RunInThreadArg* arg = new RunInThreadArg(&data, i, n);
data.evb.runInEventBaseThread(runInThreadTestFunc, arg);
usleep(10);
}
});
}
// Add a timeout event to run after 3 seconds.
// Otherwise loop() will return immediately since there are no events to run.
// Once the last thread exits, it will stop the loop(). However, this
// timeout also stops the loop in case there is a bug performing the normal
// stop.
data.evb.tryRunAfterDelay(std::bind(&EventBase::terminateLoopSoon, &data.evb),
3000);
TimePoint start;
data.evb.loop();
TimePoint end;
// Verify that the loop exited because all threads finished and requested it
// to stop. This should happen much sooner than the 3 second timeout.
// Assert that it happens in under a second. (This is still tons of extra
// padding.)
auto timeTaken = std::chrono::duration_cast<milliseconds>(
end.getTime() - start.getTime());
ASSERT_LT(timeTaken.count(), 1000);
VLOG(11) << "Time taken: " << timeTaken.count();
// Verify that we have all of the events from every thread
int expectedValues[numThreads];
for (uint32_t n = 0; n < numThreads; ++n) {
expectedValues[n] = 0;
}
for (deque< pair<int, int> >::const_iterator it = data.values.begin();
it != data.values.end();
++it) {
int threadID = it->first;
int value = it->second;
ASSERT_EQ(expectedValues[threadID], value);
++expectedValues[threadID];
}
for (uint32_t n = 0; n < numThreads; ++n) {
ASSERT_EQ(expectedValues[n], opsPerThread);
}
// Wait on all of the threads.
for (auto& thread: threads) {
thread.join();
}
}
示例2: TEST
// instanciate and play with gates
TEST(ALibxx, ChronoTest){
using namespace Davix::Chrono;
TimePoint pp;
ASSERT_EQ(0, pp.toTimestamp());
pp = Clock(Clock::Monolitic).now();
TimePoint copy_time = pp;
ASSERT_EQ(pp, copy_time);
copy_time = copy_time + Duration(5);
ASSERT_NE(copy_time, pp);
ASSERT_EQ(copy_time, pp + Duration(5));
ASSERT_GE(copy_time, pp);
ASSERT_GE(copy_time, pp + Duration(5));
ASSERT_GT(copy_time, pp);
ASSERT_LE(copy_time, pp + Duration(5));
ASSERT_LE(copy_time, pp + Duration(10));
ASSERT_LT(copy_time, pp + Duration(10));
ASSERT_EQ(copy_time + Duration(5), pp + Duration(10));
copy_time = pp;
ASSERT_EQ(copy_time, pp + Duration(10) - Duration(20) + Duration(10));
TimePoint dd;
ASSERT_ANY_THROW(
Duration res = dd - pp;
);
示例3: printSpatialEntities
// Print the spatial entities corresponding to the given time point and of the requested type
void printSpatialEntities(TimePoint &timePoint, const SubsetSpecificType &spatialEntityType) {
for (auto it = timePoint.getSpatialEntitiesBeginIterator(spatialEntityType);
it != timePoint.getSpatialEntitiesEndIterator(spatialEntityType); it++) {
std::cout << "\t SpatialEntity" << std::endl;
std::cout << (*(*it)).toString() << std::endl;
}
}
示例4:
void
SpatialTemporalDataReader::setTimePointValue(const pt::ptree &timePointTree, TimePoint &timePoint) {
double timePointValue;
if (timePointHasValue(timePointTree, timePointValue)) {
timePoint.setValue(timePointValue);
} else {
timePoint.setValue(std::numeric_limits<double>::max());
}
}
示例5: ofGetElapsedTimef
void TimeLine::addPoint(ofPoint _pos){
if ( (startTime == -1) || (points.size() == 0) ){
startTime = ofGetElapsedTimef();
}
TimePoint newPoint;
newPoint.set(_pos);
newPoint.time = ofGetElapsedTimef() - startTime;
points.push_back( newPoint );
}
示例6: getTimeDiffInMinute
int TimePoint::getTimeDiffInMinute(const TimePoint &another) const
{
int diff = convertToMinute() - another.convertToMinute();
if(diff < 0)
diff = -diff;
return diff;
}
示例7: getMeanAndStdErrorEndPoint
//---------------------------------------------------------------------------
void getMeanAndStdErrorEndPoint(const std::vector<TimeSeries>& timeSeries, TimePoint& mean, TimePoint& stdError)
{
assert(mean.isNull()==true);
assert(stdError.isNull()==true);
//Only set: biasA, biasB, fractionMixedPairs
const unsigned int nTimeSeries = timeSeries.size();
for (unsigned i=0; i<nTimeSeries; ++i)
{
//Get the index of the final index
const unsigned int time = timeSeries[i].timePoints.size() - 1;
mean += timeSeries[i].timePoints[time];
}
mean/=nTimeSeries;
}
示例8: setAnimationTime
inline void setAnimationTime(const TimePoint& timePoint) {
if (mode == MapMode::Still) {
return;
}
animationTime = timePoint.time_since_epoch();
};
示例9: timeSeed
static inline int32 timeSeed()
{
using namespace chrono;
static int32 count = 0;
typedef high_resolution_clock::time_point TimePoint;
typedef TimePoint::duration Duration;
TimePoint now = high_resolution_clock::now();
Duration sinceEpoch = now.time_since_epoch();
seconds secs = duration_cast<seconds>(sinceEpoch);
nanoseconds nsecs = sinceEpoch - secs;
return (int32)secs.count() ^ (int32)nsecs.count() ^ count--;
}
示例10: printTimePoint
// Print the given time point
void printTimePoint(TimePoint &timePoint) {
std::cout << "Time point " << timePoint.getValue() << std::endl;
for (std::size_t i = 0; i < NR_SUBSET_SPECIFIC_TYPES; i++) {
std::cout << "Subset specific type " << i << ": " << std::endl;
printSpatialEntities(timePoint, subsetspecific::computeSubsetSpecificType(i));
}
}
示例11:
const synfig::Node::time_set & ValueNode_DynamicList::ListEntry::get_times() const
{
synfig::ActivepointList::const_iterator j = timing_info.begin(),
end = timing_info.end();
//must remerge with all the other values because we don't know if we've changed...
times = value_node->get_times();
for(; j != end; ++j)
{
TimePoint t;
t.set_time(j->get_time());
t.set_guid(j->get_guid());
times.insert(t);
}
return times;
}
示例12: OSCTime
static inline int64 OSCTime(TimePoint const & tp)
{
using namespace chrono;
typedef typename TimePoint::duration Duration;
Duration sinceEpoch = tp.time_since_epoch();
seconds secs = duration_cast<seconds>(sinceEpoch);
nanoseconds nsecs = sinceEpoch - secs;
return ((int64)(secs.count() + kSECONDS_FROM_1900_to_1970) << 32)
+ (int64)(nsecs.count() * kNanosToOSCunits);
}
示例13: createDerivedSpatialEntity
void
SpatialTemporalDataReader::addSpatialEntityToTimePoint(const pt::ptree &spatialEntityTree,
TimePoint &timePoint) {
std::shared_ptr<SpatialEntity> spatialEntity;
SubsetSpecificType spatialEntityType;
createDerivedSpatialEntity(spatialEntityTree, spatialEntity, spatialEntityType);
setSpatialEntityScaleAndSubsystem(spatialEntityTree, spatialEntity);
setSpatialEntityMeasureValues(spatialEntityTree, spatialEntity);
timePoint.addSpatialEntityAndType(spatialEntity, spatialEntityType);
}
示例14: addNumericStateVariablesToTimePoint
void TemporalDataReader::addNumericStateVariablesToTimePoint(const std::vector<std::string> &lineTokens,
TimePoint &timePoint) {
std::size_t nrOfTokens = lineTokens.size();
for (std::size_t i = 1; i < nrOfTokens; i++) {
double observableVariableValue = StringManipulator::convert<double>(lineTokens[i]);
timePoint.addNumericStateVariable(
numericStateVariableIds[i],
observableVariableValue
);
}
}
示例15:
jobject mdr::JniStationPrediction::createJniStationPrediction(JNIEnv *env,
TimePoint timePoint,
float value,
std::string timeZone) {
auto duration = timePoint.time_since_epoch();
auto epoch = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
jlong jniEpoch = static_cast<jlong>(epoch);
jobject jniValue = mdr::JniFloat::toJni(env, value);
jstring tz = mdr::JniString::toJni(env, timeZone);
auto retVal = env->CallStaticObjectMethod(stationPredictionFactoryClass, factoryCtor, jniEpoch,
tz, jniValue);
mdr::Jni::checkException(env, true);
return retVal;
}