tools/footprint/win32-gdf.mk

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/tools/footprint/win32-gdf.mk	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,109 @@
     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 takes raw data files named ``winEmbed.dat'' and
    1.11 +# ``mozilla.dat'' produces a graph that shows memory usage and peak
    1.12 +# memory usage versus number of URLs loaded.
    1.13 +#
    1.14 +# The data files are assumed to be of the form:
    1.15 +#
    1.16 +#   <working-set-size-1> <peak-working-set-size-1>
    1.17 +#   <working-set-size-2> <peak-working-set-size-2>
    1.18 +#   ...
    1.19 +#
    1.20 +# It is also assumed that each measurement corresponds (roughly) to a
    1.21 +# URL load.
    1.22 +#
    1.23 +# You can tweak ``win32.gnuplot.in'' to change the graph's output.
    1.24 +#
    1.25 +# You should use this with ``make --unix'' (which will use
    1.26 +# sh.exe instead of cmd.exe to process commands); e.g.,
    1.27 +#
    1.28 +#   make --unix -f win32-gdf.mk \
    1.29 +#     BUSTER_URL="http://localhost/cgi-bin/buster.cgi?refresh=10"
    1.30 +#
    1.31 +# What You'll Need
    1.32 +# ----------------
    1.33 +#
    1.34 +# . Get gnuplot for Win32 from
    1.35 +#
    1.36 +#     ftp://ftp.dartmouth.edu/pub/gnuplot/gnuplot3.7cyg.zip
    1.37 +#
    1.38 +# . The "standard" cygwin tools that you probably already have. (If
    1.39 +#   you don't have 'em, see the Win32 build instructions on
    1.40 +#   mozilla.org.)
    1.41 +#
    1.42 +
    1.43 +# This script computes a line using linear regression; its output is
    1.44 +# of the form:
    1.45 +#
    1.46 +#   <b1> * x + <b0>
    1.47 +#
    1.48 +# Where <b1> is the slope and <b0> is the y-intercept.
    1.49 +LINEAR_REGRESSION=awk -f linear-regression.awk
    1.50 +
    1.51 +PROGRAM_PATH=..\\..\\dist\\win32_o.obj\\bin
    1.52 +WINEMBED_PROGRAM=winEmbed
    1.53 +MOZILLA_PROGRAM=mozilla
    1.54 +
    1.55 +GNUPLOT=wgnuplot.exe
    1.56 +BUSTER_URL=http://btek/cgi-bin/buster.cgi?refresh=10
    1.57 +
    1.58 +#----------------------------------------------------------------------
    1.59 +# Top-level target
    1.60 +#
    1.61 +all: win32-gdf.png
    1.62 +
    1.63 +#----------------------------------------------------------------------
    1.64 +# winEmbed
    1.65 +#
    1.66 +
    1.67 +.INTERMEDIATE: winEmbed-ws.dat winEmbed-pws.dat mozilla-ws.dat mozilla-pws.dat win32.gnuplot
    1.68 +
    1.69 +# Create a PNG image using the generated ``win32.gnuplot'' script
    1.70 +win32-gdf.png: winEmbed-ws.dat winEmbed-pws.dat mozilla-ws.dat mozilla-pws.dat win32.gnuplot
    1.71 +	$(GNUPLOT) win32.gnuplot
    1.72 +
    1.73 +# Generate a ``gnuplot'' script from ``win32.gnuplot.in'', making
    1.74 +# appropriate substitutions as necessary.
    1.75 +win32.gnuplot: win32.gnuplot.in winEmbed-ws.dat mozilla-ws.dat
    1.76 +	sed -e "s/@WINEMBED-WS-LINE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat`/" \
    1.77 +	    -e "s/@WINEMBED-GROWTH-RATE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat | awk '{ printf \"%0.1f\n\", $$1; }'`/" \
    1.78 +	    -e "s/@WINEMBED-BASE-SIZE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat | awk '{ print $$5; }'`/" \
    1.79 +	    -e "s/@MOZILLA-WS-LINE@/`$(LINEAR_REGRESSION) mozilla-ws.dat`/" \
    1.80 +	    -e "s/@MOZILLA-GROWTH-RATE@/`$(LINEAR_REGRESSION) mozilla-ws.dat | awk '{ printf \"%0.1f\n\", $$1; }'`/" \
    1.81 +	    -e "s/@MOZILLA-BASE-SIZE@/`$(LINEAR_REGRESSION) mozilla-ws.dat | awk '{ print $$5; }'`/" \
    1.82 +		win32.gnuplot.in > $@
    1.83 +
    1.84 +# Break the raw data file into temporary files that can be processed
    1.85 +# by gnuplot directly.
    1.86 +winEmbed-ws.dat: winEmbed.dat
    1.87 +	awk '{ print NR, $$1 / 1024; }' $? > $@
    1.88 +
    1.89 +winEmbed-pws.dat: winEmbed.dat
    1.90 +	awk '{ print NR, $$2 / 1024; }' $? > $@
    1.91 +
    1.92 +mozilla-ws.dat: mozilla.dat
    1.93 +	awk '{ print NR, $$1 / 1024; }' $? > $@
    1.94 +
    1.95 +mozilla-pws.dat: mozilla.dat	
    1.96 +	awk '{ print NR, $$2 / 1024; }' $? > $@
    1.97 +
    1.98 +# Run programs to collect data
    1.99 +winEmbed.dat: wm.exe
   1.100 +	cmd /c "start $(PROGRAM_PATH)\\$(WINEMBED_PROGRAM) $(BUSTER_URL) && .\\wm $(WINEMBED_PROGRAM) > $@"
   1.101 +
   1.102 +mozilla.dat: wm.exe
   1.103 +	cmd /c "start $(PROGRAM_PATH)\\$(MOZILLA_PROGRAM) $(BUSTER_URL) && .\\wm $(MOZILLA_PROGRAM) > $@"
   1.104 +
   1.105 +# Build ``wm.exe'', the memory spy
   1.106 +wm.exe: wm.cpp
   1.107 +	cl -Od -Zi wm.cpp advapi32.lib
   1.108 +
   1.109 +# Clean up the mess.
   1.110 +clean:
   1.111 +	rm -f wm.exe *-gdf.png *.dat *~
   1.112 +

mercurial