def print_table(self): import time, os, sys import statistics # if nothing was run, skip it if not len(self._table): return """Print out in a nice tabular form""" print """ ======================== distcc benchmark results ======================== """ print "Date: ", time.ctime() hosts = os.getenv('DISTCC_HOSTS') print "DISTCC_HOSTS: %s" % ` hosts ` print "Total hosts: %d" % buildutil.count_hosts(hosts) number_CPUs = os.sysconf('SC_NPROCESSORS_ONLN') print "Local number of CPUs: %s" % number_CPUs sys.stdout.flush() os.system("uname -a") print("%-20s %-30s %9s %9s %9s %9s %9s" % ('project', 'compiler', 'time', 's.d.', 'CPU time', 'CPU util', 'incl serv')) for row in self._table: print "%-20s %-30s " % row[:2], time_info_accumulator = row[2] if isinstance(time_info_accumulator, str): print ' ' * 4, time_info_accumulator else: real_times = [ time_info.real for time_info in time_info_accumulator ] Summary.print_mean_and_sd(real_times) cpu_times = [ time_info.user + time_info.system for time_info in time_info_accumulator ] self.print_mean_and_sd(cpu_times, no_sd=True) cpu_util_ratios = ([ 100 * cpu_times[i] / (number_CPUs * time_info_accumulator[i].real) for i in range(len(time_info_accumulator)) ]) self.print_mean_and_sd(cpu_util_ratios, unit='%', no_sd=True) include_server_times = [ time_info.include_server for time_info in time_info_accumulator ] if None not in include_server_times: self.print_mean_and_sd(include_server_times, no_sd=True) print
def print_table(self): import time, os, sys import statistics # if nothing was run, skip it if not len(self._table): return """Print out in a nice tabular form""" print """ ======================== distcc benchmark results ======================== """ print "Date: ", time.ctime() hosts = os.getenv('DISTCC_HOSTS') print "DISTCC_HOSTS: %s" % `hosts` print "Total hosts: %d" % buildutil.count_hosts(hosts) number_CPUs = os.sysconf('SC_NPROCESSORS_ONLN') print "Local number of CPUs: %s" % number_CPUs sys.stdout.flush() os.system("uname -a") print ("%-20s %-30s %9s %9s %9s %9s %9s" % ('project', 'compiler', 'time', 's.d.', 'CPU time', 'CPU util', 'incl serv')) for row in self._table: print "%-20s %-30s " % row[:2], time_info_accumulator = row[2] if isinstance(time_info_accumulator, str): print ' ' * 4, time_info_accumulator else: real_times = [time_info.real for time_info in time_info_accumulator] Summary.print_mean_and_sd(real_times) cpu_times = [time_info.user + time_info.system for time_info in time_info_accumulator] self.print_mean_and_sd(cpu_times, no_sd=True) cpu_util_ratios = ( [100 * cpu_times[i]/(number_CPUs * time_info_accumulator[i].real) for i in range(len(time_info_accumulator))]) self.print_mean_and_sd(cpu_util_ratios, unit='%', no_sd=True) include_server_times = [time_info.include_server for time_info in time_info_accumulator] if None not in include_server_times: self.print_mean_and_sd(include_server_times, no_sd=True) print
def parse_compiler_opt(optarg, cc, cxx): """Parse command-line specification of a compiler (-c/--compiler). XXX: I don't really know what the best syntax for this is. For the moment, it is "local", "dist", "lzo", or "pump", followed by ",h" and the number of hosts to use, followed by ",j" and the number of jobs to use (for the -j option to make). """ where, hosts, jobs = optarg.split(',') if hosts.startswith("h"): hosts = int(hosts[1:]) if not os.getenv("DISTCC_HOSTS"): raise ValueError, "You must set DISTCC_HOSTS before running benchmarks" max_hosts = buildutil.count_hosts(os.getenv("DISTCC_HOSTS")) if hosts > max_hosts: print ("Warning: can't use %d hosts: DISTCC_HOSTS only has %d" % (hosts, max_hosts)) hosts = max_hosts else: raise ValueError, ("invalid compiler option: " "expecting '...,h<NUMBER OF HOSTS>,...', found %s" % `hosts`) if jobs.startswith("j"): jobs = int(jobs[1:]) else: raise ValueError, ("invalid compiler option: " "expecting '...,j<NUMBER OF JOBS>', found %s" % `jobs`) if where == 'local': return CompilerSpec(where=where, name='local_%02d' % jobs, cc=cc, cxx=cxx, num_hosts=1, make_opts='-j%d' % jobs) elif where == 'dist': return CompilerSpec(where=where, name='dist_h%02d_j%02d' % (hosts, jobs), cc=cc, cxx=cxx, prefix='distcc ', num_hosts=hosts, make_opts='-j%d' % jobs) elif where == 'lzo': return CompilerSpec(where=where, name='lzo_h%02d_j%02d' % (hosts, jobs), cc=cc, cxx=cxx, prefix='distcc ', num_hosts=hosts, host_opts=",lzo", make_opts='-j%d' % jobs) elif where == 'pump': return CompilerSpec(where=where, name='pump_h%02d_j%02d' % (hosts, jobs), cc=cc, cxx=cxx, prefix='distcc ', pump_cmd='pump ', num_hosts=hosts, host_opts=",cpp,lzo", make_opts='-j%d' % jobs) else: raise ValueError, ("invalid compiler option: don't understand %s" % `where`)