Skip to content

Commit

Permalink
Add network request logging
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoburns committed Aug 14, 2024
1 parent 371b5ef commit 17aea05
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/dom/src/util.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::{
io::{Cursor, Read},
sync::{Arc, OnceLock},
sync::{Arc, OnceLock}, time::Instant,
};

use crate::node::{Node, NodeData};
Expand Down Expand Up @@ -33,6 +33,8 @@ impl From<std::io::Error> for FetchErr {
}

pub(crate) fn fetch_blob(url: &str) -> Result<Vec<u8>, FetchErr> {
let start = Instant::now();

// Handle data URIs
if url.starts_with("data:") {
let data_url = data_url::DataUrl::process(url).unwrap();
Expand Down Expand Up @@ -63,6 +65,9 @@ pub(crate) fn fetch_blob(url: &str) -> Result<Vec<u8>, FetchErr> {
.read_to_end(&mut bytes)
.unwrap();

let time = (Instant::now() - start).as_millis();
println!("Fetched {} in {}ms", url, time);

Ok(bytes)
}

Expand Down

0 comments on commit 17aea05

Please sign in to comment.