Skip to content

Commit

Permalink
Lua api for resetting frame stats; add decloud time to the logged stats
Browse files Browse the repository at this point in the history
  • Loading branch information
maxim-productengine committed Jan 7, 2025
1 parent 9438c86 commit 050da01
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 1 deletion.
10 changes: 10 additions & 0 deletions indra/newview/llappviewerlistener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// external library headers
// other Linden headers
#include "llappviewer.h"
#include "llviewerstats.h"
#include "workqueue.h"

LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter):
Expand All @@ -52,6 +53,10 @@ LLAppViewerListener::LLAppViewerListener(const LLAppViewerGetter& getter):
add("forceQuit",
"Quit abruptly",
&LLAppViewerListener::forceQuit);

add("resetFrameStats",
"Reset frame related stats",
&LLAppViewerListener::resetFrameStats);
}

void LLAppViewerListener::userQuit(const LLSD& event)
Expand All @@ -77,3 +82,8 @@ void LLAppViewerListener::forceQuit(const LLSD& event)
LL::WorkQueue::getInstance("mainloop")->post(
[appviewer=mAppViewerGetter()]{ appviewer->forceQuit(); });
}

void LLAppViewerListener::resetFrameStats(const LLSD& event)
{
LLViewerStats::instance().resetFrameStats();
}
1 change: 1 addition & 0 deletions indra/newview/llappviewerlistener.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class LLAppViewerListener: public LLEventAPI
void userQuit(const LLSD& event);
void requestQuit(const LLSD& event);
void forceQuit(const LLSD& event);
void resetFrameStats(const LLSD& event);

LLAppViewerGetter mAppViewerGetter;
};
Expand Down
13 changes: 12 additions & 1 deletion indra/newview/llviewerstats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,16 @@ void LLViewerStats::resetStats()
getRecording().reset();
}

void LLViewerStats::resetFrameStats()
{
mForegroundFrameStats.reset();
mBackgroundFrameStats.reset();
gForegroundTime.reset();
gForegroundFrameCount = 0;
LLStatViewer::FRAMETIME.getCurrentAccumulator().reset(NULL);
LLStatViewer::FRAMETIME_JITTER.getCurrentAccumulator().reset(NULL);
}

void LLViewerStats::updateFrameStats(const F64Seconds time_diff)
{
if (gFrameCount && mLastTimeDiff > (F64Seconds)0.0)
Expand Down Expand Up @@ -562,7 +572,8 @@ LLSD capture_viewer_stats(bool include_preferences)
}

agent["start_time"] = S32(ltime - S32(run_time));

if (gAgentAvatarp.notNull())
agent["decloud_time"] = gAgentAvatarp->getFirstDecloudTime();
agent["fg_frame_stats"] = vstats.mForegroundFrameStats.asLLSD();
agent["fg_frame_stats"]["ofr"] = ofr(vstats.mForegroundFrameStats);
agent["fg_frame_stats"]["fps"] = fps(vstats.mForegroundFrameStats);
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llviewerstats.h
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,8 @@ class LLViewerStats : public LLSingleton<LLViewerStats>
LLTrace::Recording& getRecording() { return mRecording; }
const LLTrace::Recording& getRecording() const { return mRecording; }

void resetFrameStats();

public:
StatsAccumulator mForegroundFrameStats;
StatsAccumulator mBackgroundFrameStats;
Expand Down
2 changes: 2 additions & 0 deletions indra/newview/llworld.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,8 @@ void send_agent_resume()
gMessageSystem->sendReliable(regionp->getHost());
}

// Resume updating stats in LLViewerStats::updateFrameStats
gObjectList.mWasPaused = false;
// Resume data collection to ignore invalid rates
LLViewerStats::instance().getRecording().resume();

Expand Down
2 changes: 2 additions & 0 deletions indra/newview/scripts/lua/frame_profile.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ startup = require 'startup'
sleep = (require 'timers').sleep
UI = require 'UI'
teleport_util = require('teleport_util')
--stats = require 'stats'

startup.wait('STATE_STARTED')

-- teleport to http://maps.secondlife.com/secondlife/Bug%20Island/220/224/27
print(LLAgent.teleport{regionname='Bug Island', x=220, y=224, z=27})
--teleport_util.wait()
sleep(10)
--stats.resetFrameStats()
LLAgent.setCamera{camera_pos={220, 224, 26}, camera_locked=true,
focus_pos ={228, 232, 26}, focus_locked=true}
sleep(1)
Expand Down

0 comments on commit 050da01

Please sign in to comment.