• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#! /bin/bash -u
2# Copyright 2015 The Chromium OS Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# This script takes the out.txt, generated by heatmap_generator.py
7# and sorted into a heatmap data file (inst-histo.txt) and then
8# call gnu plot to draw the heat map and the time map.
9# A heat map shows the overall hotness of instructions being executed
10# while the time map shows the hotness of instruction at different time.
11#
12# Usage:
13# ./perf-to-inst-page.sh HEATMAP_TITLE
14# HEATMAP_TITLE: the title to display on the heatmap
15
16HEAT_PNG="heat_map.png"
17TIMELINE_PNG="timeline.png"
18HEATMAP_TITLE=$1
19ENABLE_HUGEPAGE=$2
20
21heatmap_command="
22set terminal png size 600,450
23set xlabel \"Instruction Virtual Address (MB)\"
24set ylabel \"Sample Occurance\"
25set grid
26
27set output \"${HEAT_PNG}\"
28set title \"${HEATMAP_TITLE}\"
29"
30
31if [[ "${ENABLE_HUGEPAGE}" = "hugepage" ]]; then
32  hugepage_hist="inst-histo-hp.txt"
33  smallpage_hist="inst-histo-sp.txt"
34  cat out.txt | grep hugepage | awk '{print $3}' \
35    | sort -n | uniq -c > "${hugepage_hist}"
36  cat out.txt | grep smallpage | awk '{print $3}' \
37    | sort -n | uniq -c > "${smallpage_hist}"
38  # generate inst heat map
39  heatmap_in_hugepage=("'${hugepage_hist}' using \
40(\$2/1024/1024):1 with impulses notitle lt rgb 'red'")
41  heatmap_outside_hugepage=("'${smallpage_hist}' using \
42(\$2/1024/1024):1 with impulses notitle lt rgb 'blue'")
43  echo "
44  ${heatmap_command}
45  plot ${heatmap_in_hugepage}, ${heatmap_outside_hugepage}
46  " | gnuplot
47else
48  awk '{print $3}' out.txt | sort -n | uniq -c > inst-histo.txt
49  # generate inst heat map
50  echo "
51  ${heatmap_command}
52  plot 'inst-histo.txt' using (\$2/1024/1024):1 with impulses notitle
53  " | gnuplot
54fi
55
56# generate instruction page access timeline
57num=$(awk 'END {print NR+1}' out.txt)
58
59echo "
60set terminal png size 600,450
61set xlabel \"time (sec)\"
62set ylabel \"Instruction Virtual Address (MB)\"
63
64set output \"${TIMELINE_PNG}\"
65set title \"instruction page accessd timeline\"
66
67plot 'out.txt' using (\$0/$num*10):(\$3/1024/1024) with dots notitle
68" | gnuplot
69