Skip to content

Commit 82cc1fc

Browse files
Compute total counts for each column
1 parent f0ce90d commit 82cc1fc

File tree

3 files changed

+79
-10
lines changed

3 files changed

+79
-10
lines changed

site/src/api.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ pub mod status {
235235

236236
pub mod self_profile {
237237
use serde::{Deserialize, Serialize};
238+
use std::time::Duration;
238239

239240
#[derive(Debug, PartialEq, Clone, Serialize, Deserialize)]
240241
pub struct Request {
@@ -248,8 +249,25 @@ pub mod self_profile {
248249

249250
#[derive(Debug, Clone, Serialize)]
250251
pub struct Response {
251-
pub base_profile: Option<collector::SelfProfile>,
252-
pub profile: collector::SelfProfile,
252+
pub base_profile: Option<SelfProfile>,
253+
pub profile: SelfProfile,
254+
}
255+
256+
#[derive(Serialize, Deserialize, Debug, Clone)]
257+
pub struct SelfProfile {
258+
pub totals: QueryData,
259+
pub query_data: Vec<QueryData>,
260+
}
261+
262+
#[derive(Serialize, Deserialize, Clone, Debug)]
263+
pub struct QueryData {
264+
pub label: String,
265+
pub self_time: Duration,
266+
pub number_of_cache_misses: usize,
267+
pub number_of_cache_hits: usize,
268+
pub invocation_count: usize,
269+
pub blocked_time: Duration,
270+
pub incremental_load_time: Duration,
253271
}
254272
}
255273

site/src/server.rs

Lines changed: 47 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ type Request = http::Request<hyper::Body>;
4141
type Response = http::Response<hyper::Body>;
4242

4343
pub use crate::api::{
44-
self, dashboard, data, days, github, graph, info, status, CommitResponse, DateData,
45-
ServerResult,
44+
self, dashboard, data, days, github, graph, info, self_profile, status, CommitResponse,
45+
DateData, ServerResult,
4646
};
4747
use crate::git;
4848
use crate::github::post_comment;
@@ -605,7 +605,7 @@ fn get_self_profile_data(
605605
bench_name: &str,
606606
run_name: &str,
607607
sort_idx: Option<i32>,
608-
) -> ServerResult<collector::SelfProfile> {
608+
) -> ServerResult<self_profile::SelfProfile> {
609609
let benchmark = commit
610610
.benchmarks
611611
.get(bench_name)
@@ -628,11 +628,51 @@ fn get_self_profile_data(
628628
})
629629
.ok_or(format!("No such run"))?;
630630

631-
let mut profile = run
631+
let profile = run
632632
.self_profile
633633
.as_ref()
634634
.ok_or(format!("No self profile results for this commit"))?
635635
.clone();
636+
let mut profile = self_profile::SelfProfile {
637+
totals: self_profile::QueryData {
638+
label: String::from("Totals"),
639+
self_time: profile.query_data.iter().map(|qd| qd.self_time).sum(),
640+
number_of_cache_misses: profile
641+
.query_data
642+
.iter()
643+
.map(|qd| qd.number_of_cache_misses)
644+
.sum(),
645+
number_of_cache_hits: profile
646+
.query_data
647+
.iter()
648+
.map(|qd| qd.number_of_cache_hits)
649+
.sum(),
650+
invocation_count: profile
651+
.query_data
652+
.iter()
653+
.map(|qd| qd.invocation_count)
654+
.sum(),
655+
blocked_time: profile.query_data.iter().map(|qd| qd.blocked_time).sum(),
656+
incremental_load_time: profile
657+
.query_data
658+
.iter()
659+
.map(|qd| qd.incremental_load_time)
660+
.sum(),
661+
},
662+
query_data: profile
663+
.query_data
664+
.into_iter()
665+
.map(|qd| self_profile::QueryData {
666+
label: qd.label,
667+
self_time: qd.self_time,
668+
number_of_cache_misses: qd.number_of_cache_misses,
669+
number_of_cache_hits: qd.number_of_cache_hits,
670+
invocation_count: qd.invocation_count,
671+
blocked_time: qd.blocked_time,
672+
incremental_load_time: qd.incremental_load_time,
673+
})
674+
.collect(),
675+
};
636676

637677
if let Some(sort_idx) = sort_idx {
638678
loop {
@@ -668,9 +708,9 @@ fn get_self_profile_data(
668708
}
669709

670710
pub async fn handle_self_profile(
671-
body: crate::api::self_profile::Request,
711+
body: self_profile::Request,
672712
data: &InputData,
673-
) -> ServerResult<crate::api::self_profile::Response> {
713+
) -> ServerResult<self_profile::Response> {
674714
let mut it = body.benchmark.rsplitn(2, '-');
675715
let bench_ty = it.next().ok_or(format!("no benchmark type"))?;
676716
let bench_name = it.next().ok_or(format!("no benchmark name"))?;
@@ -710,7 +750,7 @@ pub async fn handle_self_profile(
710750
None
711751
};
712752

713-
Ok(crate::api::self_profile::Response {
753+
Ok(self_profile::Response {
714754
base_profile,
715755
profile,
716756
})

site/static/detailed-query.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ <h3 id="title"></h3>
140140
}
141141
let table = document.getElementById("primary-table");
142142
let idx = 0;
143-
for (let element of data.profile.query_data) {
143+
for (let element of [data.profile.totals, ...data.profile.query_data]) {
144144
let cur = to_object(element);
145145
let prev = null;
146146
if (data.base_profile) {
@@ -196,6 +196,17 @@ <h3 id="title"></h3>
196196
}
197197

198198
function to_object(element) {
199+
if (!element.length) {
200+
element = [
201+
element.label,
202+
[ element.self_time.secs, element.self_time.nanos ],
203+
element.number_of_cache_misses,
204+
element.number_of_cache_hits,
205+
element.invocation_count,
206+
[ element.blocked_time.secs, element.blocked_time.nanos ],
207+
[ element.incremental_load_time.secs, element.self_time.nanos ],
208+
];
209+
}
199210
let [
200211
label, self_time, cache_misses,
201212
_cache_hits, invocation_count, _blocked_time,

0 commit comments

Comments
 (0)