本文整理汇总了C++中TimeDuration::ToSeconds方法的典型用法代码示例。如果您正苦于以下问题:C++ TimeDuration::ToSeconds方法的具体用法?C++ TimeDuration::ToSeconds怎么用?C++ TimeDuration::ToSeconds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TimeDuration
的用法示例。
在下文中一共展示了TimeDuration::ToSeconds方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EndOfCallStats
void VideoCodecStatistics::EndOfCallStats()
{
#ifdef MOZILLA_INTERNAL_API
if (!mFirstDecodeTime.IsNull()) {
TimeDuration callDelta = TimeStamp::Now() - mFirstDecodeTime;
if (callDelta.ToSeconds() != 0) {
uint32_t recovered_per_min = mRecoveredBeforeLoss/(callDelta.ToSeconds()/60);
CSFLogError(logTag, "Video recovery before error per min %u", recovered_per_min);
#if !defined(MOZILLA_XPCOMRT_API)
Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_BEFORE_ERROR_PER_MIN,
recovered_per_min);
#endif // !defined(MOZILLA_XPCOMRT_API)
uint32_t err_per_min = mRecoveredLosses/(callDelta.ToSeconds()/60);
CSFLogError(logTag, "Video recovery after error per min %u", err_per_min);
#if !defined(MOZILLA_XPCOMRT_API)
Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_RECOVERY_AFTER_ERROR_PER_MIN,
err_per_min);
#endif // !defined(MOZILLA_XPCOMRT_API)
float percent = (mTotalLossTime.ToSeconds()*100)/callDelta.ToSeconds();
CSFLogError(logTag, "Video error time percentage %f%%", percent);
#if !defined(MOZILLA_XPCOMRT_API)
Telemetry::Accumulate(Telemetry::WEBRTC_VIDEO_DECODE_ERROR_TIME_PERMILLE,
static_cast<uint32_t>(percent*10));
#endif // !defined(MOZILLA_XPCOMRT_API)
}
}
#endif
}
示例2: GetLatestTimeStamp
// Iterate the same way we do in GetFPS()
int
FPSCounter::BuildHistogram(std::map<int, int>& aFpsData)
{
TimeStamp currentIntervalStart = GetLatestTimeStamp();
TimeStamp currentTimeStamp = GetLatestTimeStamp();
TimeStamp startTimeStamp = GetLatestTimeStamp();
int frameCount = 0;
int totalFrameCount = 0;
ResetReverseIterator();
while (HasNext(startTimeStamp)) {
currentTimeStamp = GetNextTimeStamp();
TimeDuration interval = currentIntervalStart - currentTimeStamp;
if (interval.ToSeconds() >= 1.0 ) {
currentIntervalStart = currentTimeStamp;
aFpsData[frameCount]++;
frameCount = 0;
}
frameCount++;
totalFrameCount++;
}
TimeDuration totalTime = currentIntervalStart - currentTimeStamp;
printf_stderr("Discarded %d frames over %f ms in histogram for %s\n",
frameCount, totalTime.ToMilliseconds(), mFPSName);
return totalFrameCount;
}
示例3:
double
ElementPropertyTransition::ValuePortionFor(TimeStamp aRefreshTime) const
{
// Set |timePortion| to the portion of the way we are through the time
// input to the transition's timing function (always within the range
// 0-1).
double duration = mDuration.ToSeconds();
NS_ABORT_IF_FALSE(duration >= 0.0, "negative duration forbidden");
double timePortion;
if (duration == 0.0) {
// When duration is zero, we can still have a transition when delay
// is nonzero. mStartTime already incorporates delay.
if (aRefreshTime >= mStartTime) {
timePortion = 1.0;
} else {
timePortion = 0.0;
}
} else {
timePortion = (aRefreshTime - mStartTime).ToSeconds() / duration;
if (timePortion < 0.0)
timePortion = 0.0; // use start value during transition-delay
if (timePortion > 1.0)
timePortion = 1.0; // we might be behind on flushing
}
return mTimingFunction.GetValue(timePortion);
}
示例4: Integrate
void
AxisPhysicsModel::Simulate(const TimeDuration& aDeltaTime)
{
for(mProgress += aDeltaTime.ToSeconds() / kFixedTimestep;
mProgress > 1.0; mProgress -= 1.0) {
Integrate(kFixedTimestep);
}
}
示例5:
// Returns true if we iterated over a full interval of data
bool
FPSCounter::IteratedFullInterval(TimeStamp aTimestamp, double aDuration) {
MOZ_ASSERT(mIteratorIndex >= 0, "Cannot be negative");
MOZ_ASSERT(mIteratorIndex < kMaxFrames, "Iterator index cannot be greater than kMaxFrames");
TimeStamp currentStamp = mFrameTimestamps[mIteratorIndex];
TimeDuration duration = aTimestamp - currentStamp;
return duration.ToSeconds() >= aDuration;
}
示例6: fprintf
void
FunctionTimerLog::LogString(const char *str)
{
if (mFile) {
mLatest = TimeStamp::Now();
TimeDuration elapsed = mLatest - sAppStart;
fprintf((FILE*)mFile, "[% 9.2f] %s\n", elapsed.ToSeconds() * 1000.0, str);
}
}
示例7: ref
void
BenchmarkPlayback::DrainComplete()
{
RefPtr<Benchmark> ref(mMainThreadState);
Dispatch(NS_NewRunnableFunction([this, ref]() {
int32_t frames = mFrameCount - ref->mParameters.mStartupFrame;
TimeDuration elapsedTime = TimeStamp::Now() - mDecodeStartTime;
uint32_t decodeFps = frames / elapsedTime.ToSeconds();
MainThreadShutdown();
ref->Dispatch(NS_NewRunnableFunction([ref, decodeFps]() {
ref->ReturnResult(decodeFps);
}));
}));
}
示例8: puts
void
TestLatencyParent::Main()
{
TimeDuration resolution = TimeDuration::Resolution();
if (resolution.ToSeconds() > kTimingResolutionCutoff) {
puts(" (skipping TestLatency, timing resolution is too poor)");
Close();
return;
}
printf(" timing resolution: %g seconds\n",
resolution.ToSecondsSigDigits());
if (mozilla::ipc::LoggingEnabled())
NS_RUNTIMEABORT("you really don't want to log all IPC messages during this test, trust me");
PingPongTrial();
}
示例9: FlushPendingNotifyNotUsed
void
Compositor::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
{
MOZ_ASSERT(!mIsDestroyed);
mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
// If Compositor holds many TextureHosts without compositing,
// the TextureHosts should be flushed to reduce memory consumption.
const int thresholdCount = 5;
const double thresholdSec = 2.0f;
if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
TimeDuration duration = TimeStamp::Now() - mLastCompositionEndTime;
// Check if we could flush
if (duration.ToSeconds() > thresholdSec) {
FlushPendingNotifyNotUsed();
}
}
}
示例10: GetLastCompositionEndTime
bool
TextureSourceProvider::NotifyNotUsedAfterComposition(TextureHost* aTextureHost)
{
mNotifyNotUsedAfterComposition.AppendElement(aTextureHost);
// If Compositor holds many TextureHosts without compositing,
// the TextureHosts should be flushed to reduce memory consumption.
const int thresholdCount = 5;
const double thresholdSec = 2.0f;
if (mNotifyNotUsedAfterComposition.Length() > thresholdCount) {
TimeStamp lastCompositionEndTime = GetLastCompositionEndTime();
TimeDuration duration = lastCompositionEndTime ? TimeStamp::Now() - lastCompositionEndTime : TimeDuration();
// Check if we could flush
if (duration.ToSeconds() > thresholdSec) {
FlushPendingNotifyNotUsed();
}
}
return true;
}
示例11: sizeof
void
VRDisplayOpenVR::StopPresentation()
{
if (!mIsPresenting) {
return;
}
mVRCompositor->ClearLastSubmittedFrame();
mIsPresenting = false;
const TimeDuration duration = TimeStamp::Now() - mTelemetry.mPresentationStart;
Telemetry::Accumulate(Telemetry::WEBVR_USERS_VIEW_IN, 2);
Telemetry::Accumulate(Telemetry::WEBVR_TIME_SPENT_VIEWING_IN_OPENVR,
duration.ToMilliseconds());
::vr::Compositor_CumulativeStats stats;
mVRCompositor->GetCumulativeStats(&stats, sizeof(::vr::Compositor_CumulativeStats));
const uint32_t droppedFramesPerSec = (stats.m_nNumReprojectedFrames -
mTelemetry.mLastDroppedFrameCount) / duration.ToSeconds();
Telemetry::Accumulate(Telemetry::WEBVR_DROPPED_FRAMES_IN_OPENVR, droppedFramesPerSec);
}
示例12: lock
static void
HostDB_ClearEntry(PLDHashTable *table,
PLDHashEntryHdr *entry)
{
nsHostDBEnt *he = static_cast<nsHostDBEnt*>(entry);
MOZ_ASSERT(he, "nsHostDBEnt is null!");
nsHostRecord *hr = he->rec;
MOZ_ASSERT(hr, "nsHostDBEnt has null host record!");
LOG(("Clearing cache db entry for host [%s].\n", hr->host));
#if defined(DEBUG) && defined(PR_LOGGING)
{
MutexAutoLock lock(hr->addr_info_lock);
if (!hr->addr_info) {
LOG(("No address info for host [%s].\n", hr->host));
} else {
TimeDuration diff = hr->expiration - TimeStamp::NowLoRes();
LOG(("Record for [%s] expires in %f seconds.\n", hr->host, diff.ToSeconds()));
NetAddrElement *addrElement = nullptr;
char buf[kIPv6CStrBufSize];
do {
if (!addrElement) {
addrElement = hr->addr_info->mAddresses.getFirst();
} else {
addrElement = addrElement->getNext();
}
if (addrElement) {
NetAddrToString(&addrElement->mAddress, buf, sizeof(buf));
LOG((" [%s]\n", buf));
}
}
while (addrElement);
}
}
#endif
NS_RELEASE(he->rec);
}
示例13: Output
void BenchmarkPlayback::Output(MediaDataDecoder::DecodedData&& aResults) {
MOZ_ASSERT(OnThread());
MOZ_ASSERT(!mFinished);
RefPtr<Benchmark> ref(mGlobalState);
mFrameCount += aResults.Length();
if (!mDecodeStartTime && mFrameCount >= ref->mParameters.mStartupFrame) {
mDecodeStartTime = Some(TimeStamp::Now());
}
TimeStamp now = TimeStamp::Now();
uint32_t frames = mFrameCount - ref->mParameters.mStartupFrame;
TimeDuration elapsedTime = now - mDecodeStartTime.refOr(now);
if (((frames == ref->mParameters.mFramesToMeasure) &&
mFrameCount > ref->mParameters.mStartupFrame && frames > 0) ||
elapsedTime >= ref->mParameters.mTimeout || mDrained) {
uint32_t decodeFps = frames / elapsedTime.ToSeconds();
GlobalShutdown();
ref->Dispatch(NS_NewRunnableFunction(
"BenchmarkPlayback::Output",
[ref, decodeFps]() { ref->ReturnResult(decodeFps); }));
}
}
示例14: while
// Function to complusively shut down the system with a given mode when timeout.
static void*
ForceQuitWatchdog(void* aParamPtr)
{
watchdogParam_t* paramPtr = reinterpret_cast<watchdogParam_t*>(aParamPtr);
if (paramPtr->timeoutSecs > 0 && paramPtr->timeoutSecs <= 30) {
// If we shut down normally before the timeout, this thread will
// be harmlessly reaped by the OS.
TimeStamp deadline =
(TimeStamp::Now() + TimeDuration::FromSeconds(paramPtr->timeoutSecs));
while (true) {
TimeDuration remaining = (deadline - TimeStamp::Now());
int sleepSeconds = int(remaining.ToSeconds());
if (sleepSeconds <= 0) {
break;
}
sleep(sleepSeconds);
}
}
hal::ShutdownMode mode = paramPtr->mode;
delete paramPtr;
QuitHard(mode);
return nullptr;
}
示例15:
static void
GetChromeHangReport(Telemetry::ProcessedStack& aStack,
int32_t& aSystemUptime,
int32_t& aFirefoxUptime)
{
MOZ_ASSERT(winMainThreadHandle);
// The thread we're about to suspend might have the alloc lock
// so allocate ahead of time
std::vector<uintptr_t> rawStack;
rawStack.reserve(MAX_CALL_STACK_PCS);
DWORD ret = ::SuspendThread(winMainThreadHandle);
if (ret == -1) {
return;
}
NS_StackWalk(ChromeStackWalker, /* skipFrames */ 0, /* maxFrames */ 0,
reinterpret_cast<void*>(&rawStack),
reinterpret_cast<uintptr_t>(winMainThreadHandle), nullptr);
ret = ::ResumeThread(winMainThreadHandle);
if (ret == -1) {
return;
}
aStack = Telemetry::GetStackAndModules(rawStack);
// Record system uptime (in minutes) at the time of the hang
aSystemUptime = ((GetTickCount() / 1000) - (gTimeout * 2)) / 60;
// Record Firefox uptime (in minutes) at the time of the hang
bool error;
TimeStamp processCreation = TimeStamp::ProcessCreation(error);
if (!error) {
TimeDuration td = TimeStamp::Now() - processCreation;
aFirefoxUptime = (static_cast<int32_t>(td.ToSeconds()) - (gTimeout * 2)) / 60;
} else {
aFirefoxUptime = -1;
}
}