michael@0: # -*- Mode: Makefile -*- michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: # This makefile will run Mozilla (or the program you specify), observe michael@0: # the program's memory status using the /proc filesystem, and generate michael@0: # a ``gross dynamic footprint'' graph using gnuplot. michael@0: # michael@0: # Usage: michael@0: # michael@0: # make MOZILLA_DIR= PROGRAM= URL= michael@0: # michael@0: # e.g., michael@0: # michael@0: # make -flinux-gdf.mk \ michael@0: # MOZILLA_DIR=/export2/waterson/seamonkey-opt/mozilla/dist/bin \ michael@0: # PROGRAM=gtkEmbed \ michael@0: # BUSTER_URL="http://localhost/cgi-bin/buster.cgi?refresh=10" michael@0: # michael@0: # To use this program, you'll need to: michael@0: # michael@0: # 1. Install gnuplot, e.g., using your RedHat distro. michael@0: # 2. Install the "buster.cgi" script onto a webserver somewhere michael@0: # 3. Have a mozilla build. michael@0: # michael@0: # You can tweak ``linux.gnuplot.in'' to change the graph's output. michael@0: michael@0: # This script computes a line using linear regression; its output is michael@0: # of the form: michael@0: # michael@0: # * x + michael@0: # michael@0: # Where is the slope and is the y-intercept. michael@0: LINEAR_REGRESSION=awk -f linear-regression.awk Skip=5 michael@0: michael@0: INTERVAL=10 michael@0: WATCH=./watch.sh michael@0: michael@0: MOZILLA_DIR=../../dist/bin michael@0: PROGRAM=gtkEmbed michael@0: BUSTER_URL=http://localhost/cgi-bin/buster.cgi?refresh=$(INTERVAL) michael@0: OUTFILE=linux.dat michael@0: michael@0: #---------------------------------------------------------------------- michael@0: # Top-level target michael@0: # michael@0: all: gdf.png michael@0: michael@0: #---------------------------------------------------------------------- michael@0: # gtkEmbed michael@0: # michael@0: michael@0: .INTERMEDIATE: linux.gnuplot vms.dat vmd.dat vmx.dat rss.dat michael@0: michael@0: # Create a PNG image using the generated ``linux.gnuplot'' script michael@0: gdf.png: vms.dat vmd.dat vmx.dat rss.dat linux.gnuplot michael@0: gnuplot linux.gnuplot michael@0: michael@0: # Generate a ``gnuplot'' script from ``linux.gnuplot.in'', making michael@0: # appropriate substitutions as necessary. michael@0: linux.gnuplot: linux.gnuplot.in vms.dat michael@0: sed -e "s/@PROGRAM@/$(PROGRAM)/" \ michael@0: -e "s/@VMS-LINE@/`$(LINEAR_REGRESSION) vms.dat`/" \ michael@0: -e "s/@GROWTH-RATE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ printf \"%0.1lf\\n\", $$1; }'`/" \ michael@0: -e "s/@BASE-SIZE@/`$(LINEAR_REGRESSION) vms.dat | awk '{ print $$5 + 2000; }'`/" \ michael@0: linux.gnuplot.in > linux.gnuplot michael@0: michael@0: # Break the raw data file into temporary files that can be processed michael@0: # by gnuplot directly. michael@0: vms.dat: $(OUTFILE) michael@0: awk -f create_dat.awk TYPE=vms $? > $@ michael@0: michael@0: vmd.dat: $(OUTFILE) michael@0: awk -f create_dat.awk TYPE=vmd $? > $@ michael@0: michael@0: vmx.dat: $(OUTFILE) michael@0: awk -f create_dat.awk TYPE=vmx $? > $@ michael@0: michael@0: rss.dat: $(OUTFILE) michael@0: awk -f create_dat.awk TYPE=rss $? > $@ michael@0: michael@0: # Run $(PROGRAM) to produce $(OUTFILE) michael@0: $(OUTFILE): michael@0: LD_LIBRARY_PATH=$(MOZILLA_DIR) \ michael@0: MOZILLA_FIVE_HOME=$(MOZILLA_DIR) \ michael@0: $(WATCH) -i $(INTERVAL) -o $@ $(MOZILLA_DIR)/$(PROGRAM) "$(BUSTER_URL)" michael@0: michael@0: # Clean up the mess. michael@0: clean: michael@0: rm -f $(OUTFILE) gdf.png *~ michael@0: