Skip to content

Instantly share code, notes, and snippets.

@ap29600
Last active April 21, 2025 11:31
Show Gist options
  • Save ap29600/6899e8b34a80736c5a46978d73fc157e to your computer and use it in GitHub Desktop.
Save ap29600/6899e8b34a80736c5a46978d73fc157e to your computer and use it in GitHub Desktop.
generate heatmaps from performance data in K
abcdefghijklmnopqrstuvwxyz0123456789.+-_/
a##
#
####
# #
# #
####
b
#
####
# #
# #
# #
####
c##
# #
#
#
#
####
d
#
####
# #
# #
# #
####
e##
# #
#####
#
#
####
f##
#
#
####
#
#
#
g###
# #
# #
####
#
###
h
#
# ##
## #
# #
# #
# #
i
##
#
#
#
###
j
##
#
#
#
##
k
#
# #
###
# #
# #
# #
l
#
#
#
#
#
##
m# ##
# # #
# # #
# # #
# # #
# # #
n ##
## #
# #
# #
# #
# #
o##
# #
# #
# #
# #
###
p##
# #
# #
####
#
#
q##
# #
# #
####
#
#
r ###
##
#
#
#
#
s##
#
###
#
#
####
t
####
#
#
#
#
##
u #
# #
# #
# #
# ##
## #
v #
# #
# #
# #
# #
#
w # #
# # #
# # #
# # #
# # #
## ##
x #
# #
#
# #
# #
# #
y #
# #
# #
####
#
###
z####
#
#
#
#
#####
0##
# #
# # #
# # #
# # #
# #
###
1
##
#
#
#
#
#####
2##
# #
#
#
#
#
#####
3###
#
#
##
#
#
####
4
##
# #
# #
#####
#
#
5####
#
####
#
#
# #
###
6##
# #
#
####
# #
# #
###
7####
# #
#
#
#
#
#
8##
# #
# #
###
# #
# #
###
9##
# #
# #
####
#
# #
###
.#
##
+
#
#####
#
#
-####
_####
/
#
#
#
#
#
#
(a;b;c;d;p):!2 2 2 2 2
r:@'[4#,p;i;:;(a;b;c;d)@'i:&'((~a=b)&(~c=d)&a=c;(~b=d)&(~a=c)&a=b;(~c=a)&(~d=b)&d=c;(~d=c)&(~b=a)&b=d)]
r:2 2#/:+r
nudge0:{,/(x#0#y;x_y)@>0,x}
nudge:{nudge0[x 0;nudge0'[x 1;y]]}
AdvMAME2x:{,/,'/'r@2/0^(-1 0;0 1;0 -1;1 0;0 0)nudge\:x}
AdvMAME4x:2 AdvMAME2x/
writePPM:{[c;f;d] f 1:"\n"/("P6";$#*d;$#d;"255";,//0x00^c@d)}
tile:{:[0=#x; y; 1=#x; ,'/@[;!*x]''y; ,/,'/'.[;!'2#x]''o[2_x]''y]}
rotate:{,'/(x[1]_'y;x[1]#'y:,/(x[0]_y;x[0]#y)@<0,x[0])@<0,x[1]}
PAD:5
CELLSZ:30 45
FONT: {x!~^(#[x],0N)#y}.(*:;1_)@\:0:`"font"
FONTSZ:#'-1_*:\FONT" "
DIGITS:6
COLORMAP: `c$_+/(|1(1-)\-/1_:\i)*256!(0xff0000;0xff00ff;0x0000ff;0x00ffff;0x00ff00)@0 1+\:_i:4*%/|1!:\256
data: `c`p`w1`w2`t!/:+'0N 5#/:`I$`B$1:'x
speedup: (`ln@%/:\:/2#,data[`t])@\:\:.=data[0;`c]
shape: #'-1_*:\**speedup
heatmap:tile[PAD+CELLSZ*shape]@({CELLSZ[0]}#{CELLSZ[1]}#')''_127+127*speedup%|/|/1-:\,//speedup
text:rotate[--2!CELLSZ-FONTSZ*1,DIGITS]0^tile[(PAD+CELLSZ*shape),CELLSZ,FONTSZ 1;FONT DIGITS$$100*-1+`exp speedup]
labels: AdvMAME4x' ,'/' FONT[x]
inds:((-2!(CELLSZ*shape)-/:FONTSZ[0],'4*FONTSZ[1]*#'x)+(!#x)*\:PAD+CELLSZ*shape)+!''(#'-1_*:\)'labels
text:text {.[x;y 0;:;y 1]}/ (,'inds),','labels
writePPM[COLORMAP;"out.ppm";(-PAD)_(-PAD)_'(256*text)+(~text)*256^heatmap]
@gitonthescene
Copy link

Super cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment