tools/footprint/linux-gdf.mk

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/footprint/linux-gdf.mk	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,93 @@
     1.4 +# -*- Mode: Makefile -*-
     1.5 +#
     1.6 +# This Source Code Form is subject to the terms of the Mozilla Public
     1.7 +# License, v. 2.0. If a copy of the MPL was not distributed with this
     1.8 +# file, You can obtain one at http://mozilla.org/MPL/2.0/.
     1.9 +
    1.10 +# This makefile will run Mozilla (or the program you specify), observe
    1.11 +# the program's memory status using the /proc filesystem, and generate
    1.12 +# a ``gross dynamic footprint'' graph using gnuplot.
    1.13 +#
    1.14 +# Usage:
    1.15 +#
    1.16 +#   make MOZILLA_DIR=<mozilla-dir> PROGRAM=<program> URL=<url>
    1.17 +#
    1.18 +# e.g.,
    1.19 +#
    1.20 +#   make -flinux-gdf.mk \
    1.21 +#     MOZILLA_DIR=/export2/waterson/seamonkey-opt/mozilla/dist/bin \
    1.22 +#     PROGRAM=gtkEmbed \
    1.23 +#     BUSTER_URL="http://localhost/cgi-bin/buster.cgi?refresh=10"
    1.24 +#
    1.25 +# To use this program, you'll need to:
    1.26 +#
    1.27 +# 1. Install gnuplot, e.g., using your RedHat distro.
    1.28 +# 2. Install the "buster.cgi" script onto a webserver somewhere
    1.29 +# 3. Have a mozilla build.
    1.30 +#
    1.31 +# You can tweak ``linux.gnuplot.in'' to change the graph's output.
    1.32 +
    1.33 +# This script computes a line using linear regression; its output is
    1.34 +# of the form:
    1.35 +#
    1.36 +#   <b1> * x + <b0>
    1.37 +#
    1.38 +# Where <b1> is the slope and <b0> is the y-intercept.
    1.39 +LINEAR_REGRESSION=awk -f linear-regression.awk Skip=5
    1.40 +
    1.41 +INTERVAL=10
    1.42 +WATCH=./watch.sh
    1.43 +
    1.44 +MOZILLA_DIR=../../dist/bin
    1.45 +PROGRAM=gtkEmbed
    1.46 +BUSTER_URL=http://localhost/cgi-bin/buster.cgi?refresh=$(INTERVAL)
    1.47 +OUTFILE=linux.dat
    1.48 +
    1.49 +#----------------------------------------------------------------------
    1.50 +# Top-level target
    1.51 +#
    1.52 +all: gdf.png
    1.53 +
    1.54 +#----------------------------------------------------------------------
    1.55 +# gtkEmbed
    1.56 +#
    1.57 +
    1.58 +.INTERMEDIATE: linux.gnuplot vms.dat vmd.dat vmx.dat rss.dat
    1.59 +
    1.60 +# Create a PNG image using the generated ``linux.gnuplot'' script
    1.61 +gdf.png: vms.dat vmd.dat vmx.dat rss.dat linux.gnuplot
    1.62 +	gnuplot linux.gnuplot
    1.63 +
    1.64 +# Generate a ``gnuplot'' script from ``linux.gnuplot.in'', making
    1.65 +# appropriate substitutions as necessary.
    1.66 +linux.gnuplot: linux.gnuplot.in vms.dat
    1.67 +	sed -e "s/@PROGRAM@/$(PROGRAM)/" \
    1.68 +            -e "s/@VMS-LINE@/`$(LINEAR_REGRESSION) vms.dat`/" \
    1.69 +	    -e "s/@GROWTH-RATE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ printf \"%0.1lf\\n\", $$1; }'`/" \
    1.70 +	    -e "s/@BASE-SIZE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ print $$5 + 2000; }'`/" \
    1.71 +		linux.gnuplot.in > linux.gnuplot
    1.72 +
    1.73 +# Break the raw data file into temporary files that can be processed
    1.74 +# by gnuplot directly.
    1.75 +vms.dat: $(OUTFILE)
    1.76 +	awk -f create_dat.awk TYPE=vms $? > $@
    1.77 +
    1.78 +vmd.dat: $(OUTFILE)
    1.79 +	awk -f create_dat.awk TYPE=vmd $? > $@
    1.80 +
    1.81 +vmx.dat: $(OUTFILE)
    1.82 +	awk -f create_dat.awk TYPE=vmx $? > $@
    1.83 +
    1.84 +rss.dat: $(OUTFILE)
    1.85 +	awk -f create_dat.awk TYPE=rss $? > $@
    1.86 +
    1.87 +# Run $(PROGRAM) to produce $(OUTFILE)
    1.88 +$(OUTFILE):
    1.89 +	LD_LIBRARY_PATH=$(MOZILLA_DIR) \
    1.90 +	MOZILLA_FIVE_HOME=$(MOZILLA_DIR) \
    1.91 +	$(WATCH) -i $(INTERVAL) -o $@ $(MOZILLA_DIR)/$(PROGRAM) "$(BUSTER_URL)"
    1.92 +
    1.93 +# Clean up the mess.
    1.94 +clean:
    1.95 +	rm -f $(OUTFILE) gdf.png *~
    1.96 +

mercurial