Skip to content
This repository has been archived by the owner on Jan 7, 2020. It is now read-only.

Commit

Permalink
Update look, and include all external deps inline for stand-alone rep…
Browse files Browse the repository at this point in the history
…orts
  • Loading branch information
thoughtpolice committed Feb 20, 2012
1 parent fb7282a commit 8da54a1
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 36 deletions.
2 changes: 1 addition & 1 deletion Development/Shake/CLI.hs
Expand Up @@ -49,4 +49,4 @@ shakeWithArgs r = do
when (shakeDump x) $ do
-- FIXME: custom output file?
putStrLn "note: creating build system report in 'report.html'"
Shake.buildReportTemplate (shakeFiles x <.> ".js") "report.html"
Shake.buildReport (shakeFiles x <.> ".js") "report.html"
44 changes: 30 additions & 14 deletions Development/Shake/Report.hs
Expand Up @@ -12,7 +12,7 @@
-- shake build options.
--
module Development.Shake.Report
( buildReportTemplate -- :: FilePath -> FilePath -> IO ()
( buildReport -- :: FilePath -> FilePath -> IO ()
) where
import Data.ByteString as B (ByteString, readFile)
import Data.ByteString.Lazy as BL
Expand All @@ -24,28 +24,44 @@ import System.IO.Unsafe (unsafePerformIO)
import System.FilePath
import Paths_shake_extras (getDataFileName)

data ReportCtx
= C { ctxBootstrapCSS :: B.ByteString
, ctxBootstrapRCSS :: B.ByteString
, ctxBootstrapJS :: B.ByteString
, ctxJquery :: B.ByteString
, ctxFlot :: B.ByteString
, ctxShakeDump :: B.ByteString
}

-- | Path to extras directory so we can find the report template, etc.
extrasDir :: FilePath
extrasDir = unsafePerformIO $ getDataFileName "extras"
{-# NOINLINE extrasDir #-}

-- | Takes a filepath pointing to the Shake \".js\" profiling dump.
-- Second path indicates the output file to write.
buildReportTemplate :: FilePath -> FilePath -> IO ()
buildReportTemplate jsfile out = do
js <- B.readFile jsfile
buildReport :: FilePath -> FilePath -> IO ()
buildReport jsfile out = do
bcss <- B.readFile $ bdir </> "css" </> "bootstrap.min.css"
brcss <- B.readFile $ bdir </> "css" </> "bootstrap-responsive.min.css"
bjs <- B.readFile $ bdir </> "js" </> "bootstrap.min.js"
jquery <- B.readFile $ extrasDir </> "jquery-1.6.4.min.js"
flot <- B.readFile $ extrasDir </> "jquery.flot.min.js"
shakejs <- B.readFile jsfile

let conf = H.defaultConfig { muEscapeFunc = H.emptyEscape }
BL.writeFile out =<< (hastacheFile conf (extrasDir </> "report.html") (context js))
let ctx = C bcss brcss bjs jquery flot shakejs
BL.writeFile out =<< (hastacheFile conf (extrasDir </> "report.html") (context ctx))
-- removeFile jsfile
return ()
where bdir = extrasDir </> "bootstrap"

context :: Monad m => B.ByteString -> MuContext m
context shakejs = H.mkStrContext $ \name -> case name of
"bootstrapcss" -> MuVariable $ bdir </> "css" </> "bootstrap.min.css"
"bootstraprcss" -> MuVariable $ bdir </> "css" </> "bootstrap-responsive.min.css"
"bootstrapjs" -> MuVariable $ bdir </> "js" </> "bootstrap.min.js"
"jquery" -> MuVariable $ extrasDir </> "jquery-1.6.4.min.js"
"flot" -> MuVariable $ extrasDir </> "jquery.flot.min.js"
"shakedump" -> MuVariable $ shakejs
context :: Monad m => ReportCtx -> MuContext m
context ctx = H.mkStrContext $ \name -> case name of
"bootstrapcss" -> MuVariable $ ctxBootstrapCSS ctx
"bootstraprcss" -> MuVariable $ ctxBootstrapRCSS ctx
"bootstrapjs" -> MuVariable $ ctxBootstrapJS ctx
"jquery" -> MuVariable $ ctxJquery ctx
"flot" -> MuVariable $ ctxFlot ctx
"shakedump" -> MuVariable $ ctxShakeDump ctx
_ -> MuNothing
where bdir = extrasDir </> "bootstrap"
61 changes: 40 additions & 21 deletions extras/report.html
Expand Up @@ -8,7 +8,7 @@
<meta name="author" content="N/A">

<!-- Le styles -->
<link href="{{bootstrapcss}}" rel="stylesheet">
<style>{{bootstrapcss}}</style>
<style>
body {
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
Expand All @@ -18,7 +18,7 @@
.bar div {height: 10px; background-color:#6DC067;}
.right {text-align: right;}
</style>
<link href="{{bootstraprcss}}" rel="stylesheet">
<style>{{bootstraprcss}}</style>

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
Expand All @@ -33,15 +33,22 @@ <h1>Shake Summary Report</h1>
</div> <!-- /page-header -->

<div class="row">
<div class="span4" id="summary"></div>
<div class="span4" id="summary">
<h2>Overview</h2>
</div>
<div class="span8" id="graph">
<h2>Traced commands</h2>
<div id="shakeplot" style="width:400px;height:200px;"></div>
<div id="shakeplot" style="width:600px;height:200px;"></div>
</div>
</div> <!-- /row -->
<hr>
<div class="row">
<div class="span6" id="rules"></div>
<div class="span6" id="commands"></div>
<div class="span6" id="rules">
<h2>Expensive rules</h2>
</div>
<div class="span6" id="commands">
<h2>Expensive commands</h2>
</div>
</div> <!-- /row -->
<hr>
<footer>
Expand All @@ -53,9 +60,9 @@ <h2>Traced commands</h2>
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="{{jquery}}"></script>
<script src="{{flot}}"></script>
<!-- <script src="{{bootstrapjs}}"></script> -->
<script>{{jquery}}</script>
<script>{{flot}}</script>
<!-- <script>{{bootstrapjs}}</script> -->

<!-- Profiling output -->
<script>{{shakedump}}</script>
Expand Down Expand Up @@ -212,7 +219,6 @@ <h2>Traced commands</h2>
}

var summary =
"<h2>Overview</h2>" +
"<ul>" +
"<li><strong>Runs:</strong> This database has tracked " + built.length + " run" + plural(built.length) + ".</li>" +
"<li><strong>Rules:</strong> There are " + shake.length + " rules (" + countLast + " rebuilt in the last run).</li>" +
Expand All @@ -221,7 +227,7 @@ <h2>Traced commands</h2>
"<li><strong>Longest steps:</strong> The longest rule takes " + showTime(maxExecution) + ", and the longest traced command takes " + showTime(maxTrace) + ".</li>" +
"<li><strong>Parallelism:</strong> Last run gave an average parallelism of " + (sumTrace / maxTraceStopLast).toFixed(2) + " times over " + showTime(maxTraceStopLast) + ".</li>" +
"</ul>";
$('#summary').html(summary);
$('#summary').append(summary);


/////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -257,19 +263,24 @@ <h2>Traced commands</h2>
maxBucket = Math.max(maxBucket, buckets[i]);
maxBucket = Math.ceil(maxBucket - 0.00001);

var url = "cht=lc&amp;chs=500x250&amp;chco=22AA47&amp;chm=B,6DC097,0,0,0&amp;chxt=y&amp;chxl=0:|0|" + maxBucket + "&amp;chls=3,1,0&amp;chd=t:";
plotvals = [];
for (var i = 0; i < countBuckets; i++) {
for (var i = 0; i < countBuckets; i++)
plotvals.push([i, (buckets[i] * 100 / maxBucket)]);
//url += (i == 0 ? "" : ",") + (buckets[i] * 100 / maxBucket);
}

$.plot($('#shakeplot'), [plotvals]);

/////////////////////////////////////////////////////////////////
// MOST EXPENSIVE RULES

var top = shake.slice(0).sort(function(a,b){return b.execution-a.execution}).slice(0,15);
var rules = "<h2>Expensive rules</h2><br/><table id='details'>";
var rules = "<table id='details' class='table'>";
rules += "<thead><tr>";
rules += "<th>Bar</th>";
rules += "<th>Time</th>";
rules += "<th>Overall %</th>";
rules += "<th>Rule</th>";
rules += "</tr></thead>";
rules += "<tbody>";
for (var i = 0; i < top.length; i++)
{
rules += "<tr>" +
Expand All @@ -279,8 +290,8 @@ <h2>Traced commands</h2>
"<td>" + top[i].name + "</td>" +
"</tr>";
}
rules += "</table>";
$('#rules').html(rules);
rules += "</tbody></table>";
$('#rules').append(rules);

/////////////////////////////////////////////////////////////////
// MOST EXPENSIVE COMMANDS
Expand All @@ -295,7 +306,15 @@ <h2>Traced commands</h2>
}

toolList = huffman(15, tooList);
var commands = "<h2>Expensive commands</h2><br/><table id='details'>";
var commands = "<table id='details' class='table'>";
commands += "<thead><tr>";
commands += "<th>Bar</th>";
commands += "<th>Time</th>";
commands += "<th>Overall %</th>";
commands += "<th>Invocations</th>";
commands += "<th>Name</th>";
commands += "</tr></thead>";
commands += "<tbody>";
for (var i = 0; i < toolList.length; i++)
{
commands += "<tr>" +
Expand All @@ -306,8 +325,8 @@ <h2>Traced commands</h2>
"<td>" + toolList[i].name + "</td>" +
"</tr>";
}
commands += "</table>";
$('#commands').html(commands);
commands += "</tbody></table>";
$('#commands').append(commands);
}
</script>
</body>
Expand Down

0 comments on commit 8da54a1

Please sign in to comment.