diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-02-14 00:43:53 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-14 00:43:53 +0100 |
commit | bd6ddd9b469b01b3663bbd275b7b11f7ac6e1ec2 (patch) | |
tree | 653285454e444f17b00f000c2e6c5bb72015c260 /core/snapshot_util.rs | |
parent | f917d2e2c10e0a94e564a9016217e7ce27c8bbee (diff) |
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 <crowlkats@toaxl.com>
Diffstat (limited to 'core/snapshot_util.rs')
-rw-r--r-- | core/snapshot_util.rs | 20 |
1 files changed, 16 insertions, 4 deletions
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<dyn AsRef<[u8]>> = 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() ); } |