diff --git a/src/engine/mod.rs b/src/engine/mod.rs index 74701b0..9ff4108 100644 --- a/src/engine/mod.rs +++ b/src/engine/mod.rs @@ -1,6 +1,6 @@ use std::collections::HashSet; use std::sync::Arc; -use std::time::Duration; +use std::time::{Duration, Instant}; use failure::Error; use futures::Future; @@ -46,7 +46,8 @@ impl Engine { } pub struct AnalyzeDependenciesOutcome { - pub crates: Vec<(CrateName, AnalyzedDependencies)> + pub crates: Vec<(CrateName, AnalyzedDependencies)>, + pub duration: Duration } impl AnalyzeDependenciesOutcome { @@ -70,6 +71,8 @@ impl Engine { pub fn analyze_dependencies(&self, repo_path: RepoPath) -> impl Future { + let start = Instant::now(); + let entry_point = RelativePath::new("/").to_relative_path_buf(); let manifest_future = CrawlManifestFuture::new(self, repo_path, entry_point); @@ -81,7 +84,13 @@ impl Engine { analyzed_deps_future.map(move |analyzed_deps| (crate_name, analyzed_deps)) }); - join_all(futures).map(|crates| AnalyzeDependenciesOutcome { crates }) + join_all(futures).map(move |crates| { + let duration = start.elapsed(); + + AnalyzeDependenciesOutcome { + crates, duration + } + }) }) } diff --git a/src/server/views/html/error.rs b/src/server/views/html/error.rs index c4753c4..554c14a 100644 --- a/src/server/views/html/error.rs +++ b/src/server/views/html/error.rs @@ -14,6 +14,6 @@ pub fn render(title: &str, descr: &str) -> Response { } } } - (super::render_footer()) + (super::render_footer(None)) }) } diff --git a/src/server/views/html/index.rs b/src/server/views/html/index.rs index 2270b61..80ba95b 100644 --- a/src/server/views/html/index.rs +++ b/src/server/views/html/index.rs @@ -50,6 +50,6 @@ pub fn render(popular: Vec) -> Response { section class="section" { div class="container" (popular_table(popular)) } - (super::render_footer()) + (super::render_footer(None)) }) } diff --git a/src/server/views/html/mod.rs b/src/server/views/html/mod.rs index b3cc367..8d5c572 100644 --- a/src/server/views/html/mod.rs +++ b/src/server/views/html/mod.rs @@ -1,4 +1,5 @@ use std::env; +use std::time::Duration; use hyper::Response; use hyper::header::ContentType; @@ -53,7 +54,9 @@ fn render_navbar() -> Markup { } } -fn render_footer() -> Markup { +fn render_footer(duration: Option) -> Markup { + let duration_millis = duration.map(|d| d.as_secs() * 1000 + (d.subsec_nanos() / 1000 / 1000) as u64); + html! { footer class="footer" { div class="container" { @@ -69,6 +72,9 @@ fn render_footer() -> Markup { a href="https://github.com/srijs/deps.rs/issues" "issue tracker" "." } + @if let Some(millis) = duration_millis { + p class="has-text-grey is-size-7" (format!("(rendered in {} ms)", millis)) + } } } } diff --git a/src/server/views/html/status.rs b/src/server/views/html/status.rs index 1934859..87c9f79 100644 --- a/src/server/views/html/status.rs +++ b/src/server/views/html/status.rs @@ -107,7 +107,7 @@ fn render_failure(repo_path: RepoPath) -> Markup { } } } - (super::render_footer()) + (super::render_footer(None)) } } @@ -153,7 +153,7 @@ fn render_success(analysis_outcome: AnalyzeDependenciesOutcome, repo_path: RepoP } } } - (super::render_footer()) + (super::render_footer(Some(analysis_outcome.duration))) } }