mirror of
https://github.com/deps-rs/deps.rs.git
synced 2024-11-26 03:56:30 +00:00
track rendering duration in footer
This commit is contained in:
parent
5c605c9ce8
commit
6557312468
5 changed files with 23 additions and 8 deletions
|
@ -1,6 +1,6 @@
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::time::Duration;
|
use std::time::{Duration, Instant};
|
||||||
|
|
||||||
use failure::Error;
|
use failure::Error;
|
||||||
use futures::Future;
|
use futures::Future;
|
||||||
|
@ -46,7 +46,8 @@ impl Engine {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct AnalyzeDependenciesOutcome {
|
pub struct AnalyzeDependenciesOutcome {
|
||||||
pub crates: Vec<(CrateName, AnalyzedDependencies)>
|
pub crates: Vec<(CrateName, AnalyzedDependencies)>,
|
||||||
|
pub duration: Duration
|
||||||
}
|
}
|
||||||
|
|
||||||
impl AnalyzeDependenciesOutcome {
|
impl AnalyzeDependenciesOutcome {
|
||||||
|
@ -70,6 +71,8 @@ impl Engine {
|
||||||
pub fn analyze_dependencies(&self, repo_path: RepoPath) ->
|
pub fn analyze_dependencies(&self, repo_path: RepoPath) ->
|
||||||
impl Future<Item=AnalyzeDependenciesOutcome, Error=Error>
|
impl Future<Item=AnalyzeDependenciesOutcome, Error=Error>
|
||||||
{
|
{
|
||||||
|
let start = Instant::now();
|
||||||
|
|
||||||
let entry_point = RelativePath::new("/").to_relative_path_buf();
|
let entry_point = RelativePath::new("/").to_relative_path_buf();
|
||||||
let manifest_future = CrawlManifestFuture::new(self, repo_path, entry_point);
|
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))
|
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
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,6 @@ pub fn render(title: &str, descr: &str) -> Response {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
(super::render_footer())
|
(super::render_footer(None))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,6 @@ pub fn render(popular: Vec<Repository>) -> Response {
|
||||||
section class="section" {
|
section class="section" {
|
||||||
div class="container" (popular_table(popular))
|
div class="container" (popular_table(popular))
|
||||||
}
|
}
|
||||||
(super::render_footer())
|
(super::render_footer(None))
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
use std::env;
|
use std::env;
|
||||||
|
use std::time::Duration;
|
||||||
|
|
||||||
use hyper::Response;
|
use hyper::Response;
|
||||||
use hyper::header::ContentType;
|
use hyper::header::ContentType;
|
||||||
|
@ -53,7 +54,9 @@ fn render_navbar() -> Markup {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_footer() -> Markup {
|
fn render_footer(duration: Option<Duration>) -> Markup {
|
||||||
|
let duration_millis = duration.map(|d| d.as_secs() * 1000 + (d.subsec_nanos() / 1000 / 1000) as u64);
|
||||||
|
|
||||||
html! {
|
html! {
|
||||||
footer class="footer" {
|
footer class="footer" {
|
||||||
div class="container" {
|
div class="container" {
|
||||||
|
@ -69,6 +72,9 @@ fn render_footer() -> Markup {
|
||||||
a href="https://github.com/srijs/deps.rs/issues" "issue tracker"
|
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))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue