3 # Copyright 2008, Intel Corporation
5 # This file is part of the Linux kernel
7 # This program file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by the
9 # Free Software Foundation; version 2 of the License.
11 # This program is distributed in the hope that it will be useful, but WITHOUT
12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 # You should have received a copy of the GNU General Public License
17 # along with this program in a file named COPYING; if not, write to the
18 # Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor,
20 # Boston, MA 02110-1301 USA
23 # Arjan van de Ven <arjan@linux.intel.com>
27 # This script turns a dmesg output into a SVG graphic that shows which
28 # functions take how much time. You can view SVG graphics with various
29 # programs, including Inkscape, The Gimp and Firefox.
32 # For this script to work, the kernel needs to be compiled with the
33 # CONFIG_PRINTK_TIME configuration option enabled, and with
34 # "initcall_debug" passed on the kernel command line.
37 # dmesg | perl scripts/bootgraph.pl > output.svg
48 if ($line =~ /([0-9\.]+)\] calling ([a-zA-Z\_]+)\+/) {
53 if ($line =~ /\@ ([0-9]+)/) {
59 if ($line =~ /([0-9\.]+)\] initcall ([a-zA-Z\_]+)\+.*returned/) {
65 if ($line =~ /Write protecting the/) {
71 print "No data found in the dmesg. Make sure CONFIG_PRINTK_TIME is enabled and\n";
72 print "that initcall_debug is passed on the kernel command line.\n\n";
74 print " dmesg | perl scripts/bootgraph.pl > output.svg\n\n";
78 print "<?xml version=\"1.0\" standalone=\"no\"?> \n";
79 print "<svg width=\"1000\" height=\"100%\" version=\"1.1\" xmlns=\"http://www.w3.org/2000/svg\">\n";
83 $styles[0] = "fill:rgb(0,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
84 $styles[1] = "fill:rgb(0,255,0);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
85 $styles[2] = "fill:rgb(255,0,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
86 $styles[3] = "fill:rgb(255,255,20);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
87 $styles[4] = "fill:rgb(255,0,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
88 $styles[5] = "fill:rgb(0,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
89 $styles[6] = "fill:rgb(0,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
90 $styles[7] = "fill:rgb(0,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
91 $styles[8] = "fill:rgb(255,0,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
92 $styles[9] = "fill:rgb(255,255,128);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
93 $styles[10] = "fill:rgb(255,128,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
94 $styles[11] = "fill:rgb(128,255,255);fill-opacity:0.5;stroke-width:1;stroke:rgb(0,0,0)";
96 my $mult = 950.0 / $maxtime;
97 my $threshold = 0.0500 / $maxtime;
101 while (($key,$value) = each %start) {
102 my $duration = $end{$key} - $start{$key};
104 if ($duration >= $threshold) {
108 if (!defined($rows{$pid})) {
109 $rows{$pid} = $rowscount;
110 $rowscount = $rowscount + 1;
112 $s = ($value - $firsttime) * $mult;
114 $e = $end{$key} * $mult;
117 $y = $rows{$pid} * 150;
120 $style = $styles[$stylecounter];
121 $stylecounter = $stylecounter + 1;
122 if ($stylecounter > 11) {
126 print "<rect x=\"$s\" width=\"$w\" y=\"$y\" height=\"145\" style=\"$style\"/>\n";
127 print "<text transform=\"translate($s2,$y2) rotate(90)\">$key</text>\n";
132 # print the time line on top
134 while ($time < $maxtime) {
135 my $s2 = $time * $mult;
136 print "<text transform=\"translate($s2,89) rotate(90)\">$time</text>\n";
This page took 0.037741 seconds and 5 git commands to generate.