// ================================================================================================ // Static method that needs to be called before any timing can be done // ================================================================================================ void Timer::StaticInit() { #ifdef __MACH__ mach_timebase_info_data_t info; mach_timebase_info(&info); sFreq = U64(1000000000.0 * F64(info.denom) / F64(info.numer) + 0.5); #endif }
void Value::doConvert(Type newType) { switch (type) { case TYPE_I32: type = newType; switch (newType) { case TYPE_I8: constant.i8 = S08(constant.i32); return; case TYPE_I16: constant.i16 = S16(constant.i32); return; case TYPE_I32: constant.i32 = S32(constant.i32); return; case TYPE_I64: constant.i64 = S64(constant.i32); return; case TYPE_F32: constant.f32 = F32(constant.i32); return; case TYPE_F64: constant.f64 = F64(constant.i32); return; default: assert_always("Unimplemented case"); return; } case TYPE_I64: type = newType; switch (newType) { case TYPE_I8: constant.i8 = S08(constant.i64); return; case TYPE_I16: constant.i16 = S16(constant.i64); return; case TYPE_I32: constant.i32 = S32(constant.i64); return; case TYPE_I64: constant.i64 = S64(constant.i64); return; case TYPE_F32: constant.f32 = F32(constant.i64); return; case TYPE_F64: constant.f64 = F64(constant.i64); return; default: assert_always("Unimplemented case"); return; } case TYPE_F32: type = newType; switch (newType) { case TYPE_I8: constant.i8 = S08(constant.f32); return; case TYPE_I16: constant.i16 = S16(constant.f32); return; case TYPE_I32: constant.i32 = S32(constant.f32); return; case TYPE_I64: constant.i64 = S64(constant.f32); return; case TYPE_F32: constant.f32 = F32(constant.f32); return; case TYPE_F64: constant.f64 = F64(constant.f32); return; default: assert_always("Unimplemented case"); return; } case TYPE_F64: type = newType; switch (newType) { case TYPE_I8: constant.i8 = S08(constant.f64); return; case TYPE_I16: constant.i16 = S16(constant.f64); return; case TYPE_I32: constant.i32 = S32(constant.f64); return; case TYPE_I64: constant.i64 = S64(constant.f64); return; case TYPE_F32: constant.f32 = F32(constant.f64); return; case TYPE_F64: constant.f64 = F64(constant.f64); return; default: assert_always("Unimplemented case"); return; } default: assert_always("Unimplemented case"); return; } }
int main(int argc,char** argv) { if(argc != 3) { std::cerr << "Usage: Disassemble in.wasm out.wast" << std::endl; return EXIT_FAILURE; } const char* inputFilename = argv[1]; const char* outputFilename = argv[2]; // Load the WASM file. IR::Module module; if(!loadBinaryModule(inputFilename,module)) { return EXIT_FAILURE; } // Print the module to WAST. Timing::Timer printTimer; const std::string wastString = WAST::print(module); Timing::logRatePerSecond("Printed WAST",printTimer,F64(wastString.size()) / 1024.0 / 1024.0,"MB"); // Write the serialized data to the output file. std::ofstream outputStream(outputFilename); outputStream.write(wastString.data(),wastString.size()); outputStream.close(); return EXIT_SUCCESS; }
F64 endHighResolutionTimer(U32 timeStore[2]) { // TODO: Factor this out? mach_timebase_info_data_t t; mach_timebase_info(&t); uint64_t a = mach_absolute_time() - *(uint64_t *)&timeStore[0]; uint64_t b = (a * t.numer) / t.denom; return F64(b) / (1000.0 * 1000.0); }
const S32 getElapsedMs() { if(mUsingPerfCounter) { // Use QPC, update remainders so we don't leak time, and return the elapsed time. QueryPerformanceCounter( (LARGE_INTEGER *) &mPerfCountNext); F64 elapsedF64 = (1000.0 * F64(mPerfCountNext - mPerfCountCurrent) / F64(mFrequency)); elapsedF64 += mPerfCountRemainderCurrent; U32 elapsed = (U32)mFloor(elapsedF64); mPerfCountRemainderNext = elapsedF64 - F64(elapsed); return elapsed; } else { // Do something naive with GTC. mTickCountNext = GetTickCount(); return mTickCountNext - mTickCountCurrent; } }
PhysicsEngine::PhysicsEngine() { mPreviousTime = (F64)( bx::getHPCounter()/F64(bx::getHPFrequency()) );; // We lock this to cause the physics thread to block until we release it. Mutex::lockMutex(PhysicsThread::smPhysicsFinishedMutex); setProcessTicks(true); mPhysicsThread = new PhysicsThread(); mPhysicsThread->start(); }
void LLStatTime::stop() { U64 end_time = getCurrentUsecs(); U64 duration = end_time - mLastTime; sum(F64(duration), end_time); //llinfos << "mTotalTimeInFrame incremented from " << mTotalTimeInFrame << " to " << (mTotalTimeInFrame + duration) << llendl; mTotalTimeInFrame += duration; #if LL_DEBUG mRunning = FALSE; #endif }
void PhysicsEngine::advanceTime( F32 timeDelta ) { if ( !mRunning ) return; F64 time = (F64)( bx::getHPCounter() / F64(bx::getHPFrequency()) ); F64 dt = (time - mPreviousTime); mPreviousTime = time; mAccumulatorTime += dt; if ( mAccumulatorTime >= mStepSize ) processPhysics(); }
void PhysicsEngine::interpolateTick( F32 delta ) { F64 time = (F64)( bx::getHPCounter()/F64(bx::getHPFrequency()) ); F64 dt = (time - mPreviousTime); mPreviousTime = time; mAccumulatorTime += dt; if ( mAccumulatorTime >= (1.0f/32.0f) ) processPhysics(); // Trigger interpolation from all physics components with dt = mAccumulatorTime for ( U32 n = 0; n < mComponents.size(); ++n) { mComponents[n]->interpolate(mAccumulatorTime / (1.0f/32.0f)); } }
PhysicsEngine::PhysicsEngine() { mAccumulatorTime = 0.0f; mStepSize = 1.0f / 60.0f; mPreviousTime = (F64)( bx::getHPCounter()/F64(bx::getHPFrequency()) ); #ifdef TORQUE_MULTITHREAD // We lock this to cause the physics thread to block until we release it. Mutex::lockMutex(smPhysicsFinishedMutex); mPhysicsThread = new PhysicsThread(mStepSize, physicsSimulate); mPhysicsThread->start(); #endif mRunning = true; setProcessTicks(true); }
// Return time to retry a request that generated an error, based on // error type and headers. Return value is seconds-since-epoch. F64 errorRetryTimestamp(S32 status) { // Retry-After takes priority LLSD retry_after = getResponseHeaders()["retry-after"]; if (retry_after.isDefined()) { // We only support the delta-seconds type S32 delta_seconds = retry_after.asInteger(); if (delta_seconds > 0) { // ...valid delta-seconds return F64(delta_seconds); } } // If no Retry-After, look for Cache-Control max-age F64 expires = 0.0; if (LLExperienceCache::expirationFromCacheControl(getResponseHeaders(), &expires)) { return expires; } // No information in header, make a guess if (status == 503) { // ...service unavailable, retry soon const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min return SERVICE_UNAVAILABLE_DELAY; } else if (status == 499) { // ...we were probably too busy, retry quickly const F64 BUSY_DELAY = 10.0; // 10 seconds return BUSY_DELAY; } else { // ...other unexpected error const F64 DEFAULT_DELAY = 3600.0; // 1 hour return DEFAULT_DELAY; } }
// Return time to retry a request that generated an error, based on // error type and headers. Return value is seconds-since-epoch. F64 errorRetryTimestamp(S32 status) { F64 now = LLFrameTimer::getTotalSeconds(); // Retry-After takes priority LLSD retry_after = mHeaders["retry-after"]; if (retry_after.isDefined()) { // We only support the delta-seconds type S32 delta_seconds = retry_after.asInteger(); if (delta_seconds > 0) { // ...valid delta-seconds return now + F64(delta_seconds); } } // If no Retry-After, look for Cache-Control max-age F64 expires = 0.0; if (LLAvatarNameCache::expirationFromCacheControl(mHeaders, &expires)) { return expires; } // No information in header, make a guess if (status == 503) { // ...service unavailable, retry soon const F64 SERVICE_UNAVAILABLE_DELAY = 600.0; // 10 min return now + SERVICE_UNAVAILABLE_DELAY; } else { // ...other unexpected error const F64 DEFAULT_DELAY = 3600.0; // 1 hour return now + DEFAULT_DELAY; } }
F64 LLFastTimerView::getTime(LLFastTimer::EFastTimerType tidx) { // Find table index S32 i; for (i=0; i<FTV_DISPLAY_NUM; i++) { if (tidx == ft_display_table[i].timer) { break; } } if (i == FTV_DISPLAY_NUM) { // walked off the end of ft_display_table without finding // the desired timer type llwarns << "Timer type " << tidx << " not known." << llendl; return F64(0.0); } S32 table_idx = i; // Add child ticks to parent U64 ticks = LLFastTimer::sCountAverage[tidx]; S32 level = ft_display_table[table_idx].level; for (i=table_idx+1; i<FTV_DISPLAY_NUM; i++) { if (ft_display_table[i].level <= level) { break; } ticks += LLFastTimer::sCountAverage[ft_display_table[i].timer]; } return (F64)ticks / (F64)LLFastTimer::countsPerSecond(); }
void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) { LLColor4 above_water_color = gColors.getColor( "NetMapOtherOwnAboveWater" ); LLColor4 below_water_color = gColors.getColor( "NetMapOtherOwnBelowWater" ); LLColor4 you_own_above_water_color = gColors.getColor( "NetMapYouOwnAboveWater" ); LLColor4 you_own_below_water_color = gColors.getColor( "NetMapYouOwnBelowWater" ); LLColor4 group_own_above_water_color = gColors.getColor( "NetMapGroupOwnAboveWater" ); LLColor4 group_own_below_water_color = gColors.getColor( "NetMapGroupOwnBelowWater" ); for (S32 i = 0; i < mMapObjects.count(); i++) { LLViewerObject* objectp = mMapObjects[i]; if (!objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment()) { continue; } const LLVector3& scale = objectp->getScale(); const LLVector3d pos = objectp->getPositionGlobal(); const F64 water_height = F64( objectp->getRegion()->getWaterHeight() ); // gWorldPointer->getWaterHeight(); F32 approx_radius = (scale.mV[VX] + scale.mV[VY]) * 0.5f * 0.5f * 1.3f; // 1.3 is a fudge LLColor4U color = above_water_color; if( objectp->permYouOwner() ) { const F32 MIN_RADIUS_FOR_OWNED_OBJECTS = 2.f; if( approx_radius < MIN_RADIUS_FOR_OWNED_OBJECTS ) { approx_radius = MIN_RADIUS_FOR_OWNED_OBJECTS; } if( pos.mdV[VZ] >= water_height ) { if ( objectp->permGroupOwner() ) { color = group_own_above_water_color; } else { color = you_own_above_water_color; } } else { if ( objectp->permGroupOwner() ) { color = group_own_below_water_color; } else { color = you_own_below_water_color; } } } else if( pos.mdV[VZ] < water_height ) { color = below_water_color; } netmap.renderScaledPointGlobal( pos, color, approx_radius ); } }
void LLViewerObjectList::renderObjectsForMap(LLNetMap &netmap) { LLColor4 above_water_color = gColors.getColor( "NetMapOtherOwnAboveWater" ); LLColor4 below_water_color = gColors.getColor( "NetMapOtherOwnBelowWater" ); LLColor4 you_own_above_water_color = gColors.getColor( "NetMapYouOwnAboveWater" ); LLColor4 you_own_below_water_color = gColors.getColor( "NetMapYouOwnBelowWater" ); LLColor4 group_own_above_water_color = gColors.getColor( "NetMapGroupOwnAboveWater" ); LLColor4 group_own_below_water_color = gColors.getColor( "NetMapGroupOwnBelowWater" ); F32 max_radius = gSavedSettings.getF32("MiniMapPrimMaxRadius"); for (S32 i = 0; i < mMapObjects.count(); i++) { LLViewerObject* objectp = mMapObjects[i]; if (!objectp->getRegion() || objectp->isOrphaned() || objectp->isAttachment()) { continue; } const LLVector3& scale = objectp->getScale(); const LLVector3d pos = objectp->getPositionGlobal(); const F64 water_height = F64( objectp->getRegion()->getWaterHeight() ); // LLWorld::getInstance()->getWaterHeight(); F32 approx_radius = (scale.mV[VX] + scale.mV[VY]) * 0.5f * 0.5f * 1.3f; // 1.3 is a fudge // Limit the size of megaprims so they don't blot out everything on the minimap. // Attempting to draw very large megaprims also causes client lag. // See DEV-17370 and SNOW-79 for details. approx_radius = llmin(approx_radius, max_radius); LLColor4U color = above_water_color; if( objectp->permYouOwner() ) { const F32 MIN_RADIUS_FOR_OWNED_OBJECTS = 2.f; if( approx_radius < MIN_RADIUS_FOR_OWNED_OBJECTS ) { approx_radius = MIN_RADIUS_FOR_OWNED_OBJECTS; } if( pos.mdV[VZ] >= water_height ) { if ( objectp->permGroupOwner() ) { color = group_own_above_water_color; } else { color = you_own_above_water_color; } } else { if ( objectp->permGroupOwner() ) { color = group_own_below_water_color; } else { color = you_own_below_water_color; } } } else if( pos.mdV[VZ] < water_height ) { color = below_water_color; } netmap.renderScaledPointGlobal( pos, color, approx_radius ); } }
F64 GetSystemTicksToSecondsScale() { return 1.0 / F64(MB_SECONDS_TO_NANOSECONDS); }
F64 Timer::GetTimeMilliseconds() const { return GetTimeSeconds() * F64(MB_SECONDS_TO_MILLISECONDS); }
LLSD LLViewerAssetStats::asLLSD(bool compact_output) { // Top-level tags static const LLSD::String tags[EVACCount] = { LLSD::String("get_texture_temp_http"), LLSD::String("get_texture_temp_udp"), LLSD::String("get_texture_non_temp_http"), LLSD::String("get_texture_non_temp_udp"), LLSD::String("get_wearable_udp"), LLSD::String("get_sound_udp"), LLSD::String("get_gesture_udp"), LLSD::String("get_other") }; // Stats Group Sub-tags. static const LLSD::String enq_tag("enqueued"); static const LLSD::String deq_tag("dequeued"); static const LLSD::String rcnt_tag("resp_count"); static const LLSD::String rmin_tag("resp_min"); static const LLSD::String rmax_tag("resp_max"); static const LLSD::String rmean_tag("resp_mean"); // MMM Group Sub-tags. static const LLSD::String cnt_tag("count"); static const LLSD::String min_tag("min"); static const LLSD::String max_tag("max"); static const LLSD::String mean_tag("mean"); const duration_t now = LLViewerAssetStatsFF::get_timestamp(); mCurRegionStats->accumulateTime(now); LLSD regions = LLSD::emptyArray(); for (PerRegionContainer::iterator it = mRegionStats.begin(); mRegionStats.end() != it; ++it) { if (0 == it->first) { // Never emit NULL UUID/handle in results. continue; } PerRegionStats & stats = *it->second; LLSD reg_stat = LLSD::emptyMap(); for (int i = 0; i < LL_ARRAY_SIZE(tags); ++i) { PerRegionStats::prs_group & group(stats.mRequests[i]); if ((! compact_output) || group.mEnqueued.getCount() || group.mDequeued.getCount() || group.mResponse.getCount()) { LLSD & slot = reg_stat[tags[i]]; slot = LLSD::emptyMap(); slot[enq_tag] = LLSD(S32(stats.mRequests[i].mEnqueued.getCount())); slot[deq_tag] = LLSD(S32(stats.mRequests[i].mDequeued.getCount())); slot[rcnt_tag] = LLSD(S32(stats.mRequests[i].mResponse.getCount())); slot[rmin_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMin().valueInUnits<LLUnits::Seconds>())); slot[rmax_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMax().valueInUnits<LLUnits::Seconds>())); slot[rmean_tag] = LLSD(F64(stats.mRequests[i].mResponse.getMean().valueInUnits<LLUnits::Seconds>())); } } if ((! compact_output) || stats.mFPS.getCount()) { LLSD & slot = reg_stat["fps"]; slot = LLSD::emptyMap(); slot[cnt_tag] = LLSD(S32(stats.mFPS.getCount())); slot[min_tag] = LLSD(F64(stats.mFPS.getMin())); slot[max_tag] = LLSD(F64(stats.mFPS.getMax())); slot[mean_tag] = LLSD(F64(stats.mFPS.getMean())); } U32 grid_x(0), grid_y(0); grid_from_region_handle(it->first, &grid_x, &grid_y); reg_stat["grid_x"] = LLSD::Integer(grid_x); reg_stat["grid_y"] = LLSD::Integer(grid_y); reg_stat["duration"] = LLSD::Real(stats.mTotalTime.valueInUnits<LLUnits::Seconds>()); regions.append(reg_stat); } LLSD ret = LLSD::emptyMap(); ret["regions"] = regions; ret["duration"] = LLSD::Real((now - mResetTimestamp).valueInUnits<LLUnits::Seconds>()); return ret; }