File tree 2 files changed +27
-0
lines changed
2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 4
4
#include " inspector/CV8InspectorChannel.h"
5
5
#include " V8Module.h"
6
6
#include " events/Events.h"
7
+ #include " CProfiler.h"
7
8
8
9
CV8ScriptRuntime::CV8ScriptRuntime ()
9
10
{
@@ -204,6 +205,28 @@ CV8ScriptRuntime::CV8ScriptRuntime()
204
205
}
205
206
206
207
RegisterEvents ();
208
+
209
+ ProcessConfigOptions ();
210
+ }
211
+
212
+ void CV8ScriptRuntime::ProcessConfigOptions ()
213
+ {
214
+ alt::config::Node moduleConfig = alt::ICore::Instance ().GetClientConfig ()[" js-module" ];
215
+ if (!moduleConfig.IsDict ()) return ;
216
+
217
+ alt::config::Node profiler = moduleConfig[" profiler" ];
218
+ if (!profiler.IsNone ())
219
+ {
220
+ try
221
+ {
222
+ bool result = profiler.ToBool ();
223
+ CProfiler::Instance ().SetIsEnabled (result);
224
+ }
225
+ catch (alt::config::Error&)
226
+ {
227
+ Log::Error << " Invalid value for 'profiler' config option" << Log::Endl;
228
+ }
229
+ }
207
230
}
208
231
209
232
void CV8ScriptRuntime::OnDispose ()
@@ -214,6 +237,8 @@ void CV8ScriptRuntime::OnDispose()
214
237
v8::V8::ShutdownPlatform ();
215
238
delete create_params.array_buffer_allocator ;
216
239
240
+ if (CProfiler::Instance ().IsEnabled ()) CProfiler::Instance ().Dump (alt::ICore::Instance ().GetClientPath ().ToString ());
241
+
217
242
CV8ScriptRuntime::SetInstance (nullptr );
218
243
delete this ;
219
244
}
Original file line number Diff line number Diff line change @@ -41,6 +41,8 @@ class CV8ScriptRuntime : public alt::IScriptRuntime
41
41
public:
42
42
CV8ScriptRuntime ();
43
43
44
+ void ProcessConfigOptions ();
45
+
44
46
void OnDispose () override ;
45
47
46
48
static void SetInstance (CV8ScriptRuntime* runtime)
You can’t perform that action at this time.
0 commit comments