Misc updates:

* adjust the timers to take a tag on the start; this allows them to be
  started/stopped independently, rather than needing to nest them

* add a few timers to get some perf info

* removed unused stuff: header_comment and html_link()

* use request.amp_query for the tarball_href


git-svn-id: http://viewvc.tigris.org/svn/viewvc/trunk@413 8cb11bc2-c004-0410-86c3-e597b4017df7
remotes/tags/V0_9
gstein 2001-12-22 11:16:05 +00:00
parent 1470ccd12f
commit caf33e7862
2 changed files with 23 additions and 20 deletions

View File

@ -12,19 +12,22 @@
#
# -----------------------------------------------------------------------
#
# Note: a t_start/t_end pair consumes about 0.00005 seconds on a P3/700.
# the lambda form (when debugging is disabled) should be even faster.
#
if 0:
import time
_stack = [ ]
_timers = { }
_times = { }
def t_start():
_stack.append(time.time())
def t_start(which):
_timers[which] = time.time()
def t_end(which):
t = time.time() - _stack.pop()
t = time.time() - _timers[which]
if _times.has_key(which):
_times[which] = _times[which] + t
else:

View File

@ -39,6 +39,11 @@ CONF_PATHNAME = None
#########################################################################
# this comes from our library; measure the startup time
import debug
debug.t_start('startup')
debug.t_start('imports')
# standard modules that we know are in the path or builtin
import sys
import os
@ -56,9 +61,10 @@ import compat
import config
import popen
import ezt
import debug
import accept
debug.t_end('imports')
#########################################################################
checkout_magic_path = '*checkout*'
@ -91,12 +97,6 @@ _FILE_HAD_ERROR = 'could not read file'
_UNREADABLE_MARKER = '//UNREADABLE-MARKER//'
header_comment = '''\
<!-- ViewCVS -- http://viewcvs.sourceforge.net/
by Greg Stein -- mailto:gstein@lyra.org
-->
'''
# for reading/writing between a couple descriptors
CHUNK_SIZE = 8192
@ -260,7 +260,7 @@ def generate_page(request, tname, data):
else:
tname = string.replace(tname, '%lang%', 'en')
debug.t_start()
debug.t_start('ezt-parse')
template = ezt.Template(os.path.join(g_install_dir, tname))
debug.t_end('ezt-parse')
@ -333,9 +333,6 @@ def clickable_path(request, path, leaf_is_link, leaf_is_file, drop_leaf):
return s
def html_link(contents, link):
return '<a href="%s">%s</a>' % (link, contents)
def prep_tags(query_dict, file_url, tags):
links = [ ]
for tag in tags:
@ -1415,10 +1412,7 @@ def view_directory(request):
tar_basename = os.path.basename(where)
if not tar_basename:
tar_basename = "cvs_root"
url = tar_basename + '.tar.gz?tarball=1'
query = sticky_query(query_dict)
if query:
url = url + '&' + query
url = tar_basename + '.tar.gz?tarball=1' + request.amp_query
data['tarball_href'] = url
http_header()
@ -2523,6 +2517,7 @@ def download_tarball(request):
fp.close()
def handle_config():
debug.t_start('load-config')
global cfg
if cfg is None:
cfg = config.Config()
@ -2542,6 +2537,8 @@ def handle_config():
"search": None,
}
debug.t_end('load-config')
def main():
# handle the configuration stuff
@ -2550,6 +2547,9 @@ def main():
# build a Request object, which contains info about the HTTP request
request = Request()
# most of the startup is done now.
debug.t_end('startup')
# is the CVS root really there?
if not os.path.isdir(request.cvsroot):
error('%s not found!\nThe server on which the CVS tree lives is '
@ -2618,7 +2618,7 @@ def main():
def run_cgi():
try:
debug.t_start()
debug.t_start('main')
main()
debug.t_end('main')
debug.dump()