An attempt at making some live graphs of relevant stats. Needs more thought.

git-svn-id: https://www.unprompted.com/svn/projects/tildefriends/trunk@3780 ed5197a5-7fde-0310-b194-c3ffbd925b24
This commit is contained in:
2022-01-21 02:53:15 +00:00
parent df0bb102dc
commit 98de9b037a
5 changed files with 1042 additions and 8 deletions

View File

@ -152,6 +152,7 @@ static JSValue _tf_task_get_parent(JSContext* context, JSValueConst this_val, in
static JSValue _tf_task_exit(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _tf_task_sandbox_require(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _tf_task_trace(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _tf_task_getStats(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static JSValue _tf_task_getFile(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv);
static void _tf_task_sendPromiseMessage(tf_task_t* from, tf_taskstub_t* to, tf_task_message_t messageType, promiseid_t promise, JSValue result);
@ -690,6 +691,17 @@ static JSValue _tf_task_trace(JSContext* context, JSValueConst this_val, int arg
return result;
}
static JSValue _tf_task_getStats(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_task_t* task = JS_GetContextOpaque(context);
JSValue result = JS_NewObject(context);
JS_SetPropertyStr(context, result, "child_count", JS_NewInt32(context, task->_child_count));
JS_SetPropertyStr(context, result, "import_count", JS_NewInt32(context, task->_import_count));
JS_SetPropertyStr(context, result, "export_count", JS_NewInt32(context, task->_export_count));
JS_SetPropertyStr(context, result, "promise_count", JS_NewInt32(context, task->_promise_count));
return result;
}
static JSValue _tf_task_getFile(JSContext* context, JSValueConst this_val, int argc, JSValueConst* argv)
{
tf_task_t* task = JS_GetContextOpaque(context);
@ -1388,6 +1400,7 @@ void tf_task_activate(tf_task_t* task)
}
JS_SetPropertyStr(context, global, "trace", JS_NewCFunction(context, _tf_task_trace, "trace", 1));
JS_SetPropertyStr(context, global, "getStats", JS_NewCFunction(context, _tf_task_getStats, "getStats", 0));
}
else
{