move buildTimeDist chart to examples

too esoteric for the front page, converting it to an example
of querying laminar db directly and using gnuplot should provide
more value to those needing deeper insights into job behaviour.
pull/137/head
Oliver Giles 4 years ago
parent 9862affd98
commit 746ab24676

@ -0,0 +1,46 @@
#!/usr/bin/env gnuplot
# Deeper insights can be obtained by querying Laminar's database directly.
# This example uses gnuplot to create a graph of the distribution of the
# average run time of jobs.
# The following will output a png...
set terminal pngcairo size 800,580 enhanced font 'Helvetica,10'
set output 'build-time-distribution.png'
# ..comment it out to use an interactive widget
# plot style
set tics font "Helvetica,10"
set title font "Helvetica,11"
set xtics nomirror
set ytics nomirror
set border 3 back lt 1 lc rgb "#808080"
set grid back lt 0 lc rgb "#d0d0d0" lw 0.5
set style line 1 lt 1 lc rgb "#7483af" lw 2
# Fetch the path to Laminar's sqlite database
db = system("echo $LAMINAR_HOME") . '/laminar.sqlite'
# Label the axes
set xtics ("<30s" 0, "30s-1m" 1, "1m-5m" 2, "5m-10m" 3, "10m-20m" 4, "20m-40m" 5, "40m-60m" 6, ">60m" 7)
set ylabel "Number of jobs"
set xlabel "Average run time"
set title "Distribution of average run times"
plot '< sqlite3 -separator $''\n'' ' . db . ' \
"WITH ba AS (SELECT name,AVG(completedAt-startedAt) a FROM builds GROUP BY name) SELECT \
COUNT(CASE WHEN a < 30 THEN 1 END), \
COUNT(CASE WHEN a >= 30 AND a < 60 THEN 1 END), \
COUNT(CASE WHEN a >= 60 AND a < 300 THEN 1 END), \
COUNT(CASE WHEN a >= 300 AND a < 600 THEN 1 END), \
COUNT(CASE WHEN a >= 600 AND a < 1200 THEN 1 END), \
COUNT(CASE WHEN a >= 1200 AND a < 2400 THEN 1 END), \
COUNT(CASE WHEN a >= 2400 AND a < 3600 THEN 1 END), \
COUNT(CASE WHEN a >= 3600 THEN 1 END) FROM ba;"' \
using 0:1 with linespoints title '' ls 1
# uncomment this if using an interactive window
#pause mouse close
# Release the output
set output

@ -458,29 +458,6 @@ std::string Laminar::getStatus(MonitorScope scope) {
j.EndObject();
});
j.EndArray();
j.startArray("buildTimeDist");
db->stmt("WITH ba AS (SELECT name,AVG(completedAt-startedAt) a FROM builds GROUP BY name) SELECT "
"COUNT(CASE WHEN a < 30 THEN 1 END),"
"COUNT(CASE WHEN a >= 30 AND a < 60 THEN 1 END),"
"COUNT(CASE WHEN a >= 60 AND a < 300 THEN 1 END),"
"COUNT(CASE WHEN a >= 300 AND a < 600 THEN 1 END),"
"COUNT(CASE WHEN a >= 600 AND a < 1200 THEN 1 END),"
"COUNT(CASE WHEN a >= 1200 AND a < 2400 THEN 1 END),"
"COUNT(CASE WHEN a >= 2400 AND a < 3600 THEN 1 END),"
"COUNT(CASE WHEN a >= 3600 THEN 1 END) FROM ba")
.fetch<uint,uint,uint,uint,uint,uint,uint,uint>([&](uint c1, uint c2, uint c3, uint c4, uint c5, uint c6, uint c7, uint c8){
j.Int(c1);
j.Int(c2);
j.Int(c3);
j.Int(c4);
j.Int(c5);
j.Int(c6);
j.Int(c7);
j.Int(c8);
});
j.EndArray();
}
j.EndObject();
return j.str();

@ -71,7 +71,6 @@
<div><canvas id="chartBpj"></canvas></div>
<div><canvas id="chartTpj"></canvas></div>
<div><canvas id="chartBuildTimeChanges"></canvas></div>
<div><canvas id="chartBuildTimeDist"></canvas></div>
</div>
</section>
</div></template>

@ -350,20 +350,6 @@ const Home = function() {
}
}
});
var chtBuildTimeDist = new Chart(document.getElementById("chartBuildTimeDist"), {
type: 'line',
data: {
labels: ['<30s','30s-1m','1m-5m','5m-10m','10m-20m','20m-40m','40m-60m','>60m'],
datasets: [{
label: 'Number jobs with average build time in range',
data: msg.buildTimeDist,
backgroundColor: "#7483af",
}]
},
options: {
title: { display: true, text: 'Build time distribution' }
}
});
},
job_queued: function(data) {
state.jobsQueued.splice(0, 0, data);

@ -45,7 +45,6 @@ TEST_F(LaminarFixture, EmptyStatusMessageStructure) {
EXPECT_TRUE(data.HasMember("resultChanged"));
EXPECT_TRUE(data.HasMember("lowPassRates"));
EXPECT_TRUE(data.HasMember("buildTimeChanges"));
EXPECT_TRUE(data.HasMember("buildTimeDist"));
}
TEST_F(LaminarFixture, JobNotifyHomePage) {

Loading…
Cancel
Save