diff options
author | Matt Mastracci <matthew@mastracci.com> | 2023-11-05 14:27:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-05 14:27:36 -0700 |
commit | 485fade0b6910e29557c6627d37985b47735bf8e (patch) | |
tree | 0f6c97c135c8a92226caecb363effe7eabf47936 /runtime/web_worker.rs | |
parent | 4530cd5f0d5e6acdbbb11a60eac711d47f274d3f (diff) |
chore: migrate to new deno_core and metrics (#21057)
- Uses the new OpMetrics system for sync and async calls
- Partial revert of #21048 as we moved Array.fromAsync upstream to
deno_core
Diffstat (limited to 'runtime/web_worker.rs')
-rw-r--r-- | runtime/web_worker.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/runtime/web_worker.rs b/runtime/web_worker.rs index 5c42d752f..3c6556da4 100644 --- a/runtime/web_worker.rs +++ b/runtime/web_worker.rs @@ -32,6 +32,7 @@ use deno_core::ModuleCode; use deno_core::ModuleId; use deno_core::ModuleLoader; use deno_core::ModuleSpecifier; +use deno_core::OpMetricsSummaryTracker; use deno_core::RuntimeOptions; use deno_core::SharedArrayBufferStore; use deno_core::Snapshot; @@ -507,6 +508,18 @@ impl WebWorker { #[cfg(all(feature = "include_js_files_for_snapshotting", feature = "dont_create_runtime_snapshot", not(feature = "__runtime_js_sources")))] options.startup_snapshot.as_ref().expect("Sources are not embedded, snapshotting was disabled and a user snapshot was not provided."); + // Hook up the summary metrics if the user or subcommand requested them + let (op_summary_metrics, op_metrics_factory_fn) = + if options.bootstrap.enable_op_summary_metrics { + let op_summary_metrics = Rc::new(OpMetricsSummaryTracker::default()); + ( + Some(op_summary_metrics.clone()), + Some(op_summary_metrics.op_metrics_factory_fn(|_| true)), + ) + } else { + (None, None) + }; + // Clear extension modules from the module map, except preserve `node:*` // modules as `node:` specifiers. let preserve_snapshotted_modules = @@ -525,9 +538,14 @@ impl WebWorker { inspector: options.maybe_inspector_server.is_some(), preserve_snapshotted_modules, feature_checker: Some(options.feature_checker.clone()), + op_metrics_factory_fn, ..Default::default() }); + if let Some(op_summary_metrics) = op_summary_metrics { + js_runtime.op_state().borrow_mut().put(op_summary_metrics); + } + if let Some(server) = options.maybe_inspector_server.clone() { server.register_inspector( main_module.to_string(), |