From bd6ddd9b469b01b3663bbd275b7b11f7ac6e1ec2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bartek=20Iwa=C5=84czuk?= Date: Tue, 14 Feb 2023 00:43:53 +0100 Subject: feat(core): allow to specify entry point for snapshotted ES modules (#17771) This commit adds "ExtensionBuilder::esm_entry_point()" function that allows to specify which of the extension files should be treated as an entry point. If the entry point is not provided all modules are loaded and evaluated, but if it is provided then only the entry point is explicitly loaded and evaluated. Co-authored-by: Leo Kettmeir --- core/snapshot_util.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'core/snapshot_util.rs') diff --git a/core/snapshot_util.rs b/core/snapshot_util.rs index 0a1793b51..7e22395e0 100644 --- a/core/snapshot_util.rs +++ b/core/snapshot_util.rs @@ -22,6 +22,7 @@ pub struct CreateSnapshotOptions { } pub fn create_snapshot(create_snapshot_options: CreateSnapshotOptions) { + let start = std::time::Instant::now(); let js_runtime = JsRuntime::new(RuntimeOptions { will_snapshot: true, startup_snapshot: create_snapshot_options.startup_snapshot, @@ -33,7 +34,12 @@ pub fn create_snapshot(create_snapshot_options: CreateSnapshotOptions) { let snapshot = js_runtime.snapshot(); let snapshot_slice: &[u8] = &snapshot; - println!("Snapshot size: {}", snapshot_slice.len()); + println!( + "Snapshot size: {}, took {}s ({})", + snapshot_slice.len(), + start.elapsed().as_secs_f64(), + create_snapshot_options.snapshot_path.display() + ); let maybe_compressed_snapshot: Box> = if let Some(compression_cb) = create_snapshot_options.compression_cb { @@ -47,7 +53,12 @@ pub fn create_snapshot(create_snapshot_options: CreateSnapshotOptions) { (compression_cb)(&mut vec, snapshot_slice); - println!("Snapshot compressed size: {}", vec.len()); + println!( + "Snapshot compressed size: {}, took {}s ({})", + vec.len(), + start.elapsed().as_secs_f64(), + create_snapshot_options.snapshot_path.display() + ); Box::new(vec) } else { @@ -60,8 +71,9 @@ pub fn create_snapshot(create_snapshot_options: CreateSnapshotOptions) { ) .unwrap(); println!( - "Snapshot written to: {} ", - create_snapshot_options.snapshot_path.display() + "Snapshot written to: {}, took: {}s", + create_snapshot_options.snapshot_path.display(), + start.elapsed().as_secs_f64() ); } -- cgit v1.2.3