diff --git a/examples/plot-build-time-dist b/examples/plot-build-time-dist new file mode 100755 index 0000000..8c3f631 --- /dev/null +++ b/examples/plot-build-time-dist @@ -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 \ No newline at end of file diff --git a/src/laminar.cpp b/src/laminar.cpp index 92dd997..63bc641 100644 --- a/src/laminar.cpp +++ b/src/laminar.cpp @@ -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 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(); diff --git a/src/resources/index.html b/src/resources/index.html index 096298a..6194064 100644 --- a/src/resources/index.html +++ b/src/resources/index.html @@ -71,7 +71,6 @@
-
diff --git a/src/resources/js/app.js b/src/resources/js/app.js index 941c2ae..9b3cf11 100644 --- a/src/resources/js/app.js +++ b/src/resources/js/app.js @@ -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); diff --git a/test/laminar-functional.cpp b/test/laminar-functional.cpp index 23e4dc1..06a6107 100644 --- a/test/laminar-functional.cpp +++ b/test/laminar-functional.cpp @@ -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) {