summaryrefslogtreecommitdiff
path: root/indra/newview
diff options
context:
space:
mode:
authorMaxim Nikolenko <maximnproductengine@lindenlab.com>2024-08-29 20:04:34 +0300
committerGitHub <noreply@github.com>2024-08-29 20:04:34 +0300
commit11e6c77129ae27756df627ccc1ea0ffa279976e6 (patch)
tree5200ec3e0774fbc3eb1c50bb2f2e76c205f58699 /indra/newview
parent6f454ad8366ed33bbe199c3fc3ed69e6d3448cec (diff)
Add simple metrics of Lua usage
Diffstat (limited to 'indra/newview')
-rw-r--r--indra/newview/llappviewer.cpp2
-rw-r--r--indra/newview/llfloaterluadebug.cpp2
-rw-r--r--indra/newview/llluamanager.cpp16
-rw-r--r--indra/newview/llluamanager.h5
-rw-r--r--indra/newview/llviewerstats.cpp5
5 files changed, 23 insertions, 7 deletions
diff --git a/indra/newview/llappviewer.cpp b/indra/newview/llappviewer.cpp
index c259275d8f..686b97390a 100644
--- a/indra/newview/llappviewer.cpp
+++ b/indra/newview/llappviewer.cpp
@@ -1252,7 +1252,7 @@ bool LLAppViewer::init()
while (scripts.next(script))
{
LL_DEBUGS("InitInfo") << "LuaAutorunPath: " << absdir << ": " << script << LL_ENDL;
- LLLUAmanager::runScriptFile((abspath / script).string());
+ LLLUAmanager::runScriptFile((abspath / script).string(), true);
}
});
diff --git a/indra/newview/llfloaterluadebug.cpp b/indra/newview/llfloaterluadebug.cpp
index ef24481464..1831edb452 100644
--- a/indra/newview/llfloaterluadebug.cpp
+++ b/indra/newview/llfloaterluadebug.cpp
@@ -127,7 +127,7 @@ void LLFloaterLUADebug::runSelectedScript(const std::vector<std::string> &filena
if (!filepath.empty())
{
mScriptPath->setText(filepath);
- LLLUAmanager::runScriptFile(filepath, [this](int count, const LLSD &result)
+ LLLUAmanager::runScriptFile(filepath, false, [this](int count, const LLSD &result)
{
completion(count, result);
});
diff --git a/indra/newview/llluamanager.cpp b/indra/newview/llluamanager.cpp
index 22b51d7b72..befd231e92 100644
--- a/indra/newview/llluamanager.cpp
+++ b/indra/newview/llluamanager.cpp
@@ -49,6 +49,8 @@
#include <string_view>
#include <vector>
+S32 LLLUAmanager::sAutorunScriptCount = 0;
+S32 LLLUAmanager::sScriptCount = 0;
std::map<std::string, std::string> LLLUAmanager::sScriptNames;
lua_function(sleep, "sleep(seconds): pause the running coroutine")
@@ -172,7 +174,7 @@ LLLUAmanager::startScriptFile(const std::string& filename)
// Despite returning from startScriptFile(), we need this Promise to
// remain alive until the callback has fired.
auto promise{ std::make_shared<LLCoros::Promise<script_result>>() };
- runScriptFile(filename,
+ runScriptFile(filename, false,
[promise](int count, LLSD result)
{ promise->set_value({ count, result }); });
return LLCoros::getFuture(*promise);
@@ -183,11 +185,11 @@ LLLUAmanager::script_result LLLUAmanager::waitScriptFile(const std::string& file
return startScriptFile(filename).get();
}
-void LLLUAmanager::runScriptFile(const std::string &filename, script_result_fn result_cb,
- script_finished_fn finished_cb)
+void LLLUAmanager::runScriptFile(const std::string &filename, bool autorun,
+ script_result_fn result_cb, script_finished_fn finished_cb)
{
// A script_result_fn will be called when LuaState::expr() completes.
- LLCoros::instance().launch(filename, [filename, result_cb, finished_cb]()
+ LLCoros::instance().launch(filename, [filename, autorun, result_cb, finished_cb]()
{
ScriptObserver observer(LLCoros::getName(), filename);
llifstream in_file;
@@ -195,6 +197,12 @@ void LLLUAmanager::runScriptFile(const std::string &filename, script_result_fn r
if (in_file.is_open())
{
+ if (autorun)
+ {
+ sAutorunScriptCount++;
+ }
+ sScriptCount++;
+
// A script_finished_fn is used to initialize the LuaState.
// It will be called when the LuaState is destroyed.
LuaState L(finished_cb);
diff --git a/indra/newview/llluamanager.h b/indra/newview/llluamanager.h
index 50f922a80f..309cb87cac 100644
--- a/indra/newview/llluamanager.h
+++ b/indra/newview/llluamanager.h
@@ -58,7 +58,7 @@ public:
// same semantics as script_result_fn parameters
typedef std::pair<int, LLSD> script_result;
- static void runScriptFile(const std::string &filename, script_result_fn result_cb = {},
+ static void runScriptFile(const std::string &filename, bool autorun = false, script_result_fn result_cb = {},
script_finished_fn finished_cb = {});
// Start running a Lua script file, returning an LLCoros::Future whose
// get() method will pause the calling coroutine until it can deliver the
@@ -84,6 +84,9 @@ public:
static const std::map<std::string, std::string> getScriptNames() { return sScriptNames; }
+ static S32 sAutorunScriptCount;
+ static S32 sScriptCount;
+
private:
static std::map<std::string, std::string> sScriptNames;
};
diff --git a/indra/newview/llviewerstats.cpp b/indra/newview/llviewerstats.cpp
index 62b4c390d0..60e8cf2e52 100644
--- a/indra/newview/llviewerstats.cpp
+++ b/indra/newview/llviewerstats.cpp
@@ -66,6 +66,7 @@
#include "llinventorymodel.h"
#include "lluiusage.h"
#include "lltranslate.h"
+#include "llluamanager.h"
// "Minimal Vulkan" to get max API Version
@@ -673,6 +674,10 @@ void send_viewer_stats(bool include_preferences)
system["shader_level"] = shader_level;
+ LLSD &scripts = body["scripts"];
+ scripts["lua_scripts"] = LLLUAmanager::sScriptCount;
+ scripts["lua_auto_scripts"] = LLLUAmanager::sAutorunScriptCount;
+
LLSD &download = body["downloads"];
download["world_kbytes"] = F64Kilobytes(gTotalWorldData).value();