1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
|
#! /usr/bin/python
# distcc/benchmark -- automated system for testing distcc correctness
# and performance on various source trees.
# Copyright (C) 2002, 2003, 2004 by Martin Pool
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2 of the
# License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA
# Unlike the main distcc test suite, this program *does* require you
# to manually set up servers on your choice of machines on the
# network, and make sure that they all have appropriate compilers
# installed. The performance measurements obviously depend on the
# network and hardware available.
# It also depends on you having the necessary dependencies to build
# the software. If you regularly build software on Linux you should
# be OK. Some things (the GIMP) will be harder than others.
# On some platforms, it may be impossible to build some targets -- for
# example, Linux depends on having a real-mode x86 assembler, which
# probably isn't installed on Solaris.
# Note that running this program will potentially download many
# megabytes of test data.
# TODO: Support applying patches after unpacking, before building.
# For example, they might be needed to fix -j bugs in the Makefile.
# TODO: In stats, show ratio of build time to slowest build time. (Or
# to first one run?)
# TODO: Allow choice of which compiler and make options to use.
# TODO: Try building something large in C++.
# TODO: Set CXX as well.
# TODO: Add option to run tests repeatedly and show mean and std. dev.
# TODO: Perhaps add option to do "make clean" -- this might be faster
# than unzipping and configuring every time. But perhaps also less
# reproducible.
# TODO: Add option to run tests on different sets or orderings of
# machines.
import re, os, sys, time
from getopt import getopt
from Summary import Summary
from Project import Project, trees
from compiler import CompilerSpec
from Build import Build
import actions, compiler
import ProjectDefs # this adds a lot of definitions to 'trees'
def error(msg):
sys.stderr.write(msg + "\n")
def list_projects():
names = trees.keys()
names.sort()
for n in names:
print n
def find_project(name):
"""
Return the nearest unique match for name.
"""
best_match = None
for pn in trees.keys():
if pn.startswith(name):
if best_match:
raise ValueError, "ambiguous prefix %s" % name
else:
best_match = pn
if not best_match:
raise ValueError, "nothing matches %s" % name
else:
return trees[best_match]
def show_help():
print """Usage: benchmark.py [OPTION]... [PROJECT]...
Test distcc relative performance building different projects.
By default, all known projects are built.
Options:
--help show brief help message
--list-projects show defined projects
-c, --compiler=COMPILER specify one compiler to use
-n N repeat compilation N times
-a, --actions=ACTIONS comma-separated list of action phases
to perform
Compilers can be specified as either "local,N" to run N copies of gcc,
or dist,N to run N copies of distcc. Multiple -c options specify
different scenarios to measure. The default is to run a nonparallel
local compile and a parallel distributed compile.
"""
actions.action_help()
# -a is for developer use only and not documented; unless you're
# careful the results will just be confusing.
######################################################################
def main():
"""Run the benchmark per arguments"""
sum = Summary()
options, args = getopt(sys.argv[1:], 'a:c:n:',
['list-projects', 'actions=', 'help', 'compiler='])
opt_actions = actions.default_actions
set_compilers = []
opt_repeats = 1
for opt, optarg in options:
if opt == '--help':
show_help()
return
elif opt == '--list-projects':
list_projects()
return
elif opt == '--actions' or opt == '-a':
opt_actions = actions.parse_opt_actions(optarg)
elif opt == '--compiler' or opt == '-c':
set_compilers.append(compiler.parse_opt(optarg))
elif opt == '-n':
opt_repeats = int(optarg)
if not set_compilers:
set_compilers = compiler.default_compilers()
# Find named projects, or run all by default
if args:
chosen_projects = [find_project(name) for name in args]
else:
chosen_projects = trees.values()
for proj in chosen_projects:
proj.pre_actions(opt_actions)
for comp in set_compilers:
build = Build(proj, comp, opt_repeats)
build.build_actions(opt_actions, sum)
sum.print_table()
if __name__ == '__main__':
main()
|