tools/footprint/win32-gdf.mk

Tue, 06 Jan 2015 21:39:09 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Tue, 06 Jan 2015 21:39:09 +0100
branch
TOR_BUG_9701
changeset 8
97036ab72558
permissions
-rw-r--r--

Conditionally force memory storage according to privacy.thirdparty.isolate;
This solves Tor bug #9701, complying with disk avoidance documented in
https://www.torproject.org/projects/torbrowser/design/#disk-avoidance.

michael@0 1 # -*- Mode: Makefile -*-
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 # This makefile takes raw data files named ``winEmbed.dat'' and
michael@0 8 # ``mozilla.dat'' produces a graph that shows memory usage and peak
michael@0 9 # memory usage versus number of URLs loaded.
michael@0 10 #
michael@0 11 # The data files are assumed to be of the form:
michael@0 12 #
michael@0 13 # <working-set-size-1> <peak-working-set-size-1>
michael@0 14 # <working-set-size-2> <peak-working-set-size-2>
michael@0 15 # ...
michael@0 16 #
michael@0 17 # It is also assumed that each measurement corresponds (roughly) to a
michael@0 18 # URL load.
michael@0 19 #
michael@0 20 # You can tweak ``win32.gnuplot.in'' to change the graph's output.
michael@0 21 #
michael@0 22 # You should use this with ``make --unix'' (which will use
michael@0 23 # sh.exe instead of cmd.exe to process commands); e.g.,
michael@0 24 #
michael@0 25 # make --unix -f win32-gdf.mk \
michael@0 26 # BUSTER_URL="http://localhost/cgi-bin/buster.cgi?refresh=10"
michael@0 27 #
michael@0 28 # What You'll Need
michael@0 29 # ----------------
michael@0 30 #
michael@0 31 # . Get gnuplot for Win32 from
michael@0 32 #
michael@0 33 # ftp://ftp.dartmouth.edu/pub/gnuplot/gnuplot3.7cyg.zip
michael@0 34 #
michael@0 35 # . The "standard" cygwin tools that you probably already have. (If
michael@0 36 # you don't have 'em, see the Win32 build instructions on
michael@0 37 # mozilla.org.)
michael@0 38 #
michael@0 39
michael@0 40 # This script computes a line using linear regression; its output is
michael@0 41 # of the form:
michael@0 42 #
michael@0 43 # <b1> * x + <b0>
michael@0 44 #
michael@0 45 # Where <b1> is the slope and <b0> is the y-intercept.
michael@0 46 LINEAR_REGRESSION=awk -f linear-regression.awk
michael@0 47
michael@0 48 PROGRAM_PATH=..\\..\\dist\\win32_o.obj\\bin
michael@0 49 WINEMBED_PROGRAM=winEmbed
michael@0 50 MOZILLA_PROGRAM=mozilla
michael@0 51
michael@0 52 GNUPLOT=wgnuplot.exe
michael@0 53 BUSTER_URL=http://btek/cgi-bin/buster.cgi?refresh=10
michael@0 54
michael@0 55 #----------------------------------------------------------------------
michael@0 56 # Top-level target
michael@0 57 #
michael@0 58 all: win32-gdf.png
michael@0 59
michael@0 60 #----------------------------------------------------------------------
michael@0 61 # winEmbed
michael@0 62 #
michael@0 63
michael@0 64 .INTERMEDIATE: winEmbed-ws.dat winEmbed-pws.dat mozilla-ws.dat mozilla-pws.dat win32.gnuplot
michael@0 65
michael@0 66 # Create a PNG image using the generated ``win32.gnuplot'' script
michael@0 67 win32-gdf.png: winEmbed-ws.dat winEmbed-pws.dat mozilla-ws.dat mozilla-pws.dat win32.gnuplot
michael@0 68 $(GNUPLOT) win32.gnuplot
michael@0 69
michael@0 70 # Generate a ``gnuplot'' script from ``win32.gnuplot.in'', making
michael@0 71 # appropriate substitutions as necessary.
michael@0 72 win32.gnuplot: win32.gnuplot.in winEmbed-ws.dat mozilla-ws.dat
michael@0 73 sed -e "s/@WINEMBED-WS-LINE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat`/" \
michael@0 74 -e "s/@WINEMBED-GROWTH-RATE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat | awk '{ printf \"%0.1f\n\", $$1; }'`/" \
michael@0 75 -e "s/@WINEMBED-BASE-SIZE@/`$(LINEAR_REGRESSION) winEmbed-ws.dat | awk '{ print $$5; }'`/" \
michael@0 76 -e "s/@MOZILLA-WS-LINE@/`$(LINEAR_REGRESSION) mozilla-ws.dat`/" \
michael@0 77 -e "s/@MOZILLA-GROWTH-RATE@/`$(LINEAR_REGRESSION) mozilla-ws.dat | awk '{ printf \"%0.1f\n\", $$1; }'`/" \
michael@0 78 -e "s/@MOZILLA-BASE-SIZE@/`$(LINEAR_REGRESSION) mozilla-ws.dat | awk '{ print $$5; }'`/" \
michael@0 79 win32.gnuplot.in > $@
michael@0 80
michael@0 81 # Break the raw data file into temporary files that can be processed
michael@0 82 # by gnuplot directly.
michael@0 83 winEmbed-ws.dat: winEmbed.dat
michael@0 84 awk '{ print NR, $$1 / 1024; }' $? > $@
michael@0 85
michael@0 86 winEmbed-pws.dat: winEmbed.dat
michael@0 87 awk '{ print NR, $$2 / 1024; }' $? > $@
michael@0 88
michael@0 89 mozilla-ws.dat: mozilla.dat
michael@0 90 awk '{ print NR, $$1 / 1024; }' $? > $@
michael@0 91
michael@0 92 mozilla-pws.dat: mozilla.dat
michael@0 93 awk '{ print NR, $$2 / 1024; }' $? > $@
michael@0 94
michael@0 95 # Run programs to collect data
michael@0 96 winEmbed.dat: wm.exe
michael@0 97 cmd /c "start $(PROGRAM_PATH)\\$(WINEMBED_PROGRAM) $(BUSTER_URL) && .\\wm $(WINEMBED_PROGRAM) > $@"
michael@0 98
michael@0 99 mozilla.dat: wm.exe
michael@0 100 cmd /c "start $(PROGRAM_PATH)\\$(MOZILLA_PROGRAM) $(BUSTER_URL) && .\\wm $(MOZILLA_PROGRAM) > $@"
michael@0 101
michael@0 102 # Build ``wm.exe'', the memory spy
michael@0 103 wm.exe: wm.cpp
michael@0 104 cl -Od -Zi wm.cpp advapi32.lib
michael@0 105
michael@0 106 # Clean up the mess.
michael@0 107 clean:
michael@0 108 rm -f wm.exe *-gdf.png *.dat *~
michael@0 109

mercurial