Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: gdb-patches@sourceware.org
Subject: Re: RFA: shrink minimal symbols
Date: Thu, 28 Aug 2008 01:40:00 -0000	[thread overview]
Message-ID: <20080828013935.GA26841@caradoc.them.org> (raw)
In-Reply-To: <m3d4ju2hzt.fsf@fleche.redhat.com>

[-- Attachment #1: Type: text/plain, Size: 372 bytes --]

On Wed, Aug 27, 2008 at 04:47:02PM -0600, Tom Tromey wrote:
> Good point.  It does slow things down a bit :(

Yeah, unfortunately that was what I suspected.  Thanks for checking.

I've attached a script I find handy when doing performance work on
GDB; the numbers are slightly more reliable this way.  I also use
'memusage' from glibc.

-- 
Daniel Jacobowitz
CodeSourcery

[-- Attachment #2: run-and-time --]
[-- Type: text/plain, Size: 4181 bytes --]

#!/usr/bin/python
import sys, urllib, htmllib, httplib, ftplib, formatter, urlparse, socket
import re, signal, getopt
import time, os, resource

import stats, string, Scientific.Statistics, Numeric

real_times = []
user_times = []
sys_times = []

total_real_times = []
total_user_times = []
total_sys_times = []

def parse_log(filename):
	global real_times, user_times, sys_times
	real_times = []
	user_times = []
	sys_times = []
	file = open(filename, "r");
	if file:
		for line in file.readlines():
			if line[-1] == '\n':
				line = line[:-1]
			words = string.split(line)
			
			if(len(words) == 2):
				if(words[0] == "real"):
					real_times.append(float(words[1]))
				if(words[0] == "user"):
					user_times.append(float(words[1]))
				if(words[0] == "sys"):
					sys_times.append(float(words[1]))
			else:
				print "Unrecognized line: " + line
	else:
		print "Can't open " + filename

def parse_log_list(filenames):
	for file in filenames:
		parse_log(file)
		if(len(total_real_times) == 0):
			total_real_times = real_times
			total_user_times = user_times
			total_sys_times = sys_times
		elif (len(total_real_times) != len(real_times)):
			print "Ignoring " + file + " - wrong number of times."
		else:
			for i in range(len(real_times)):
				total_real_times[i] += real_times[i]
				total_user_times[i] += user_times[i]
				total_sys_times[i] += sys_times[i]

def run_once(command):
	start_real = time.time()
	rusage = resource.getrusage(resource.RUSAGE_CHILDREN)
	start_user = rusage.ru_utime
	start_sys = rusage.ru_stime

	ret = os.spawnvp(os.P_WAIT, command[0], command)

	total_real_times.append(time.time() - start_real)
	rusage = resource.getrusage(resource.RUSAGE_CHILDREN)
	total_user_times.append(rusage.ru_utime - start_user)
	total_sys_times.append(rusage.ru_stime - start_sys)

	if ret > 0:
		print 'Exited with status %d' % ret
	elif ret < 0:
		print 'Exited with signal %d' % -ret

def dump_times():
	times = []
	for i in xrange(niters):
		times.append((total_real_times[i], total_user_times[i], total_sys_times[i]))
	times.sort(lambda x, y: cmp(x[0], y[0]))
	for time in times:
		print "real %8.5fs    user %8.5fs    sys %8.5fs" \
		      % time

def run_command(command, niters):
	for i in xrange(niters):
		run_once(command)

	# dump_times()

	min = 0
	for i in xrange(niters):
		if total_real_times[i] < total_real_times[min]:
			min = i
	print "Minimum:  real %8.5fs    user %8.5fs    sys %8.5fs" \
	      % (total_real_times[min], total_user_times[min], total_sys_times[min])
	del total_real_times[min]
	del total_user_times[min]
	del total_sys_times[min]	
	
	max = 0
	for i in xrange(niters-1):
		if total_real_times[i] > total_real_times[max]:
			max = i
	print "Maximum:  real %8.5fs    user %8.5fs    sys %8.5fs" \
	      % (total_real_times[max], total_user_times[max], total_sys_times[max])
	del total_real_times[max]
	del total_user_times[max]
	del total_sys_times[max]

files = False
niters = 5

opts, args = getopt.getopt (sys.argv[1:], 'fn:')

for pair in opts:
	if pair[0] == '-f':
		files = True
	elif pair[0] == '-n':
		niters = int(pair[1])
	else:
		sys.exit(1)

if (files):
	parse_log_list(args)
else:
	run_command(args, niters)

total_real_times = Numeric.array (total_real_times, Numeric.Float)
total_sys_times = Numeric.array (total_sys_times, Numeric.Float)
total_user_times = Numeric.array (total_user_times, Numeric.Float)

real_average = Scientific.Statistics.average(total_real_times)
#real_variance = Scientific.Statistics.variance(total_real_times)
real_stddev = Scientific.Statistics.standardDeviation(total_real_times)

user_average = Scientific.Statistics.average(total_user_times)
#user_variance = Scientific.Statistics.variance(total_user_times)
user_stddev = Scientific.Statistics.standardDeviation(total_user_times)

sys_average = Scientific.Statistics.average(total_sys_times)
#sys_variance = Scientific.Statistics.variance(total_sys_times)
sys_stddev = Scientific.Statistics.standardDeviation(total_sys_times)

print "Average:  real %8.5fs    user %8.5fs    sys %8.5fs" % (real_average, user_average, sys_average)
print "StdDev:   real %8.5f     user %8.5f     sys %8.5f" % (real_stddev, user_stddev, sys_stddev)

      reply	other threads:[~2008-08-28  1:40 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-08-27 20:01 Tom Tromey
2008-08-27 20:58 ` Daniel Jacobowitz
2008-08-27 22:48   ` Tom Tromey
2008-08-28  1:40     ` Daniel Jacobowitz [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080828013935.GA26841@caradoc.them.org \
    --to=drow@false.org \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox