Last active
December 11, 2015 04:09
-
-
Save gkossakowski/4543164 to your computer and use it in GitHub Desktop.
A helper script that generates little timeline out of data dumped by https://github.com/gkossakowski/scalac-aspects#typing-timings-typingtimingsaj
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val input = Stream.continually(Console.readLine).takeWhile(_ != null) | |
val parsed = input.map(_.trim.split("\\s+").toSeq) | |
//parsed.take(100).foreach(println) | |
/** see CSS definition */ | |
def color(hash: Int): String = { | |
val hashAbs = math.abs(hash) | |
val colors = Seq("primary", "secondary-a", "secondary-b", "complement") | |
val col = colors((hashAbs/10) % (colors.size)) | |
val variant = 1 + (hashAbs % 5) | |
col + "-" + variant | |
} | |
val html = | |
<html> | |
<head> | |
<style type="text/css"> | |
/** | |
* CSS Timeline Styles | |
*/ | |
ul.events {{ | |
list-style-type: none; | |
margin: 0; | |
padding: 0 0 20px 0; | |
}} | |
ul.events li {{ | |
-webkit-border-radius: 11px; | |
-moz-border-radius: 11px; | |
border-radius: 11px; | |
border: 1px solid #ddd; | |
color: white; | |
font-size: 0.7em; | |
font-weight: bold; | |
margin-bottom: 6px; | |
padding: 3px 0; | |
position: relative; | |
text-align: center; | |
}} | |
/* Palette color codes, http://colorschemedesigner.com/#0061Tw0w0w0w0 */ | |
.primary-1 {{ background-color: #FF0000 }} | |
.primary-2 {{ background-color: #BF3030 }} | |
.primary-3 {{ background-color: #A60000 }} | |
.primary-4 {{ background-color: #FF4040 }} | |
.primary-5 {{ background-color: #FF7373 }} | |
.secondary-a-1 {{ background-color: #FF7400 }} | |
.secondary-a-2 {{ background-color: #BF7130 }} | |
.secondary-a-3 {{ background-color: #A64B00 }} | |
.secondary-a-4 {{ background-color: #FF9640 }} | |
.secondary-a-5 {{ background-color: #FFB273 }} | |
.secondary-b-1 {{ background-color: #CD0074 }} | |
.secondary-b-2 {{ background-color: #992667 }} | |
.secondary-b-3 {{ background-color: #85004B }} | |
.secondary-b-4 {{ background-color: #E6399B }} | |
.secondary-b-5 {{ background-color: #E667AF }} | |
.complement-1 {{ background-color: #00CC00 }} | |
.complement-2 {{ background-color: #269926 }} | |
.complement-3 {{ background-color: #008500 }} | |
.complement-4 {{ background-color: #39E639 }} | |
.complement-5 {{ background-color: #67E667 }} | |
/* end */ | |
ul.events li em {{ | |
color: #aaa; | |
font-weight: normal; | |
font-size: 0.9em; | |
}} | |
</style> | |
</head> | |
<body> | |
<div class="timeline"> | |
<ul class="events"> | |
{ | |
val scalingFactor = 0.014 | |
//val scalingFactor = 0.02 | |
val baseStartTime = parsed.map(_.apply(0).toInt).min | |
for { | |
Seq(startTime, duration, lazyTpeName, name, pos) <- parsed.sortBy(_.apply(0).toInt) if duration.toInt * scalingFactor > 10 | |
} yield { | |
val st = (startTime.toInt - baseStartTime) * scalingFactor | |
val d = duration.toInt * scalingFactor | |
<li class={color(lazyTpeName.hashCode)} style={s"width: ${d}px; left: ${st}px;"} | |
title={s"[$lazyTpeName] $name"}>{name}</li> | |
} | |
} | |
</ul> <!-- end .events --> | |
</div> <!-- end .timeline --> | |
</body> | |
</html> | |
println("""<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">""") | |
println(html) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment