| #! /bin/bash -u |
| # Copyright 2015 The Chromium OS Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| # This script takes the out.txt, generated by heatmap_generator.py |
| # and sorted into a heatmap data file (inst-histo.txt) and then |
| # call gnu plot to draw the heat map and the time map. |
| # A heat map shows the overall hotness of instructions being executed |
| # while the time map shows the hotness of instruction at different time. |
| # |
| # Usage: |
| # ./perf-to-inst-page.sh HEATMAP_TITLE |
| # HEATMAP_TITLE: the title to display on the heatmap |
| |
| HEAT_PNG="heat_map.png" |
| TIMELINE_PNG="timeline.png" |
| HEATMAP_TITLE=$1 |
| |
| awk '{print $3}' out.txt | sort -n | uniq -c > inst-histo.txt |
| |
| # generate inst heat map |
| echo " |
| set terminal png size 600,450 |
| set xlabel \"Instruction Virtual Address (MB)\" |
| set ylabel \"Sample Occurance\" |
| set grid |
| |
| set output \"${HEAT_PNG}\" |
| set title \"${HEATMAP_TITLE}\" |
| |
| plot 'inst-histo.txt' using (\$2/1024/1024):1 with impulses notitle |
| " | gnuplot |
| |
| # generate instruction page access timeline |
| num=$(awk 'END {print NR+1}' out.txt) |
| |
| echo " |
| set terminal png size 600,450 |
| set xlabel \"time (sec)\" |
| set ylabel \"Instruction Virtual Address (MB)\" |
| |
| set output \"${TIMELINE_PNG}\" |
| set title \"instruction page accessd timeline\" |
| |
| plot 'out.txt' using (\$0/$num*10):(\$3/1024/1024) with dots notitle |
| " | gnuplot |