summaryrefslogtreecommitdiff
path: root/runtime
diff options
context:
space:
mode:
Diffstat (limited to 'runtime')
-rw-r--r--runtime/web_worker.rs18
-rw-r--r--runtime/worker.rs18
-rw-r--r--runtime/worker_bootstrap.rs2
3 files changed, 38 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(),
diff --git a/runtime/worker.rs b/runtime/worker.rs
index 2e2910109..4775b474c 100644
--- a/runtime/worker.rs
+++ b/runtime/worker.rs
@@ -27,6 +27,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;
@@ -324,6 +325,18 @@ impl MainWorker {
}
}
+ // 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)
+ };
+
extensions.extend(std::mem::take(&mut options.extensions));
#[cfg(all(feature = "include_js_files_for_snapshotting", feature = "dont_create_runtime_snapshot", not(feature = "__runtime_js_sources")))]
@@ -349,9 +362,14 @@ impl MainWorker {
inspector: options.maybe_inspector_server.is_some(),
is_main: true,
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(),
diff --git a/runtime/worker_bootstrap.rs b/runtime/worker_bootstrap.rs
index b21b4aa21..9f2393ba4 100644
--- a/runtime/worker_bootstrap.rs
+++ b/runtime/worker_bootstrap.rs
@@ -44,6 +44,7 @@ pub struct BootstrapOptions {
pub args: Vec<String>,
pub cpu_count: usize,
pub log_level: WorkerLogLevel,
+ pub enable_op_summary_metrics: bool,
pub enable_testing_features: bool,
pub locale: String,
pub location: Option<ModuleSpecifier>,
@@ -79,6 +80,7 @@ impl Default for BootstrapOptions {
cpu_count,
no_color: !colors::use_color(),
is_tty: colors::is_tty(),
+ enable_op_summary_metrics: Default::default(),
enable_testing_features: Default::default(),
log_level: Default::default(),
ts_version: Default::default(),