PageRenderTime 43ms CodeModel.GetById 7ms RepoModel.GetById 0ms app.codeStats 0ms

/couchjs/scons/scons-time.py

http://github.com/cloudant/bigcouch
Python | 1544 lines | 1466 code | 7 blank | 71 comment | 23 complexity | 5720328971b0d4ac8f2453b25c3c3dcc MD5 | raw file
Possible License(s): Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. #!/usr/bin/env python
  2. #
  3. # scons-time - run SCons timings and collect statistics
  4. #
  5. # A script for running a configuration through SCons with a standard
  6. # set of invocations to collect timing and memory statistics and to
  7. # capture the results in a consistent set of output files for display
  8. # and analysis.
  9. #
  10. #
  11. # Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010 The SCons Foundation
  12. #
  13. # Permission is hereby granted, free of charge, to any person obtaining
  14. # a copy of this software and associated documentation files (the
  15. # "Software"), to deal in the Software without restriction, including
  16. # without limitation the rights to use, copy, modify, merge, publish,
  17. # distribute, sublicense, and/or sell copies of the Software, and to
  18. # permit persons to whom the Software is furnished to do so, subject to
  19. # the following conditions:
  20. #
  21. # The above copyright notice and this permission notice shall be included
  22. # in all copies or substantial portions of the Software.
  23. #
  24. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
  25. # KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  26. # WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  27. # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  28. # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  29. # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  30. # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  31. from __future__ import division
  32. from __future__ import nested_scopes
  33. __revision__ = "src/script/scons-time.py 5134 2010/08/16 23:02:40 bdeegan"
  34. import getopt
  35. import glob
  36. import os
  37. import re
  38. import shutil
  39. import sys
  40. import tempfile
  41. import time
  42. try:
  43. sorted
  44. except NameError:
  45. # Pre-2.4 Python has no sorted() function.
  46. #
  47. # The pre-2.4 Python list.sort() method does not support
  48. # list.sort(key=) nor list.sort(reverse=) keyword arguments, so
  49. # we must implement the functionality of those keyword arguments
  50. # by hand instead of passing them to list.sort().
  51. def sorted(iterable, cmp=None, key=None, reverse=False):
  52. if key is not None:
  53. result = [(key(x), x) for x in iterable]
  54. else:
  55. result = iterable[:]
  56. if cmp is None:
  57. # Pre-2.3 Python does not support list.sort(None).
  58. result.sort()
  59. else:
  60. result.sort(cmp)
  61. if key is not None:
  62. result = [t1 for t0,t1 in result]
  63. if reverse:
  64. result.reverse()
  65. return result
  66. if os.environ.get('SCONS_HORRIBLE_REGRESSION_TEST_HACK') is not None:
  67. # We can't apply the 'callable' fixer until the floor is 2.6, but the
  68. # '-3' option to Python 2.6 and 2.7 generates almost ten thousand
  69. # warnings. This hack allows us to run regression tests with the '-3'
  70. # option by replacing the callable() built-in function with a hack
  71. # that performs the same function but doesn't generate the warning.
  72. # Note that this hack is ONLY intended to be used for regression
  73. # testing, and should NEVER be used for real runs.
  74. from types import ClassType
  75. def callable(obj):
  76. if hasattr(obj, '__call__'): return True
  77. if isinstance(obj, (ClassType, type)): return True
  78. return False
  79. def make_temp_file(**kw):
  80. try:
  81. result = tempfile.mktemp(**kw)
  82. try:
  83. result = os.path.realpath(result)
  84. except AttributeError:
  85. # Python 2.1 has no os.path.realpath() method.
  86. pass
  87. except TypeError:
  88. try:
  89. save_template = tempfile.template
  90. prefix = kw['prefix']
  91. del kw['prefix']
  92. tempfile.template = prefix
  93. result = tempfile.mktemp(**kw)
  94. finally:
  95. tempfile.template = save_template
  96. return result
  97. def HACK_for_exec(cmd, *args):
  98. '''
  99. For some reason, Python won't allow an exec() within a function
  100. that also declares an internal function (including lambda functions).
  101. This function is a hack that calls exec() in a function with no
  102. internal functions.
  103. '''
  104. if not args: exec(cmd)
  105. elif len(args) == 1: exec cmd in args[0]
  106. else: exec cmd in args[0], args[1]
  107. class Plotter(object):
  108. def increment_size(self, largest):
  109. """
  110. Return the size of each horizontal increment line for a specified
  111. maximum value. This returns a value that will provide somewhere
  112. between 5 and 9 horizontal lines on the graph, on some set of
  113. boundaries that are multiples of 10/100/1000/etc.
  114. """
  115. i = largest // 5
  116. if not i:
  117. return largest
  118. multiplier = 1
  119. while i >= 10:
  120. i = i // 10
  121. multiplier = multiplier * 10
  122. return i * multiplier
  123. def max_graph_value(self, largest):
  124. # Round up to next integer.
  125. largest = int(largest) + 1
  126. increment = self.increment_size(largest)
  127. return ((largest + increment - 1) // increment) * increment
  128. class Line(object):
  129. def __init__(self, points, type, title, label, comment, fmt="%s %s"):
  130. self.points = points
  131. self.type = type
  132. self.title = title
  133. self.label = label
  134. self.comment = comment
  135. self.fmt = fmt
  136. def print_label(self, inx, x, y):
  137. if self.label:
  138. print 'set label %s "%s" at %s,%s right' % (inx, self.label, x, y)
  139. def plot_string(self):
  140. if self.title:
  141. title_string = 'title "%s"' % self.title
  142. else:
  143. title_string = 'notitle'
  144. return "'-' %s with lines lt %s" % (title_string, self.type)
  145. def print_points(self, fmt=None):
  146. if fmt is None:
  147. fmt = self.fmt
  148. if self.comment:
  149. print '# %s' % self.comment
  150. for x, y in self.points:
  151. # If y is None, it usually represents some kind of break
  152. # in the line's index number. We might want to represent
  153. # this some way rather than just drawing the line straight
  154. # between the two points on either side.
  155. if not y is None:
  156. print fmt % (x, y)
  157. print 'e'
  158. def get_x_values(self):
  159. return [ p[0] for p in self.points ]
  160. def get_y_values(self):
  161. return [ p[1] for p in self.points ]
  162. class Gnuplotter(Plotter):
  163. def __init__(self, title, key_location):
  164. self.lines = []
  165. self.title = title
  166. self.key_location = key_location
  167. def line(self, points, type, title=None, label=None, comment=None, fmt='%s %s'):
  168. if points:
  169. line = Line(points, type, title, label, comment, fmt)
  170. self.lines.append(line)
  171. def plot_string(self, line):
  172. return line.plot_string()
  173. def vertical_bar(self, x, type, label, comment):
  174. if self.get_min_x() <= x and x <= self.get_max_x():
  175. points = [(x, 0), (x, self.max_graph_value(self.get_max_y()))]
  176. self.line(points, type, label, comment)
  177. def get_all_x_values(self):
  178. result = []
  179. for line in self.lines:
  180. result.extend(line.get_x_values())
  181. return [r for r in result if not r is None]
  182. def get_all_y_values(self):
  183. result = []
  184. for line in self.lines:
  185. result.extend(line.get_y_values())
  186. return [r for r in result if not r is None]
  187. def get_min_x(self):
  188. try:
  189. return self.min_x
  190. except AttributeError:
  191. try:
  192. self.min_x = min(self.get_all_x_values())
  193. except ValueError:
  194. self.min_x = 0
  195. return self.min_x
  196. def get_max_x(self):
  197. try:
  198. return self.max_x
  199. except AttributeError:
  200. try:
  201. self.max_x = max(self.get_all_x_values())
  202. except ValueError:
  203. self.max_x = 0
  204. return self.max_x
  205. def get_min_y(self):
  206. try:
  207. return self.min_y
  208. except AttributeError:
  209. try:
  210. self.min_y = min(self.get_all_y_values())
  211. except ValueError:
  212. self.min_y = 0
  213. return self.min_y
  214. def get_max_y(self):
  215. try:
  216. return self.max_y
  217. except AttributeError:
  218. try:
  219. self.max_y = max(self.get_all_y_values())
  220. except ValueError:
  221. self.max_y = 0
  222. return self.max_y
  223. def draw(self):
  224. if not self.lines:
  225. return
  226. if self.title:
  227. print 'set title "%s"' % self.title
  228. print 'set key %s' % self.key_location
  229. min_y = self.get_min_y()
  230. max_y = self.max_graph_value(self.get_max_y())
  231. incr = (max_y - min_y) / 10.0
  232. start = min_y + (max_y / 2.0) + (2.0 * incr)
  233. position = [ start - (i * incr) for i in range(5) ]
  234. inx = 1
  235. for line in self.lines:
  236. line.print_label(inx, line.points[0][0]-1,
  237. position[(inx-1) % len(position)])
  238. inx += 1
  239. plot_strings = [ self.plot_string(l) for l in self.lines ]
  240. print 'plot ' + ', \\\n '.join(plot_strings)
  241. for line in self.lines:
  242. line.print_points()
  243. def untar(fname):
  244. import tarfile
  245. tar = tarfile.open(name=fname, mode='r')
  246. for tarinfo in tar:
  247. tar.extract(tarinfo)
  248. tar.close()
  249. def unzip(fname):
  250. import zipfile
  251. zf = zipfile.ZipFile(fname, 'r')
  252. for name in zf.namelist():
  253. dir = os.path.dirname(name)
  254. try:
  255. os.makedirs(dir)
  256. except:
  257. pass
  258. open(name, 'w').write(zf.read(name))
  259. def read_tree(dir):
  260. for dirpath, dirnames, filenames in os.walk(dir):
  261. for fn in filenames:
  262. fn = os.path.join(dirpath, fn)
  263. if os.path.isfile(fn):
  264. open(fn, 'rb').read()
  265. def redirect_to_file(command, log):
  266. return '%s > %s 2>&1' % (command, log)
  267. def tee_to_file(command, log):
  268. return '%s 2>&1 | tee %s' % (command, log)
  269. class SConsTimer(object):
  270. """
  271. Usage: scons-time SUBCOMMAND [ARGUMENTS]
  272. Type "scons-time help SUBCOMMAND" for help on a specific subcommand.
  273. Available subcommands:
  274. func Extract test-run data for a function
  275. help Provides help
  276. mem Extract --debug=memory data from test runs
  277. obj Extract --debug=count data from test runs
  278. time Extract --debug=time data from test runs
  279. run Runs a test configuration
  280. """
  281. name = 'scons-time'
  282. name_spaces = ' '*len(name)
  283. def makedict(**kw):
  284. return kw
  285. default_settings = makedict(
  286. aegis = 'aegis',
  287. aegis_project = None,
  288. chdir = None,
  289. config_file = None,
  290. initial_commands = [],
  291. key_location = 'bottom left',
  292. orig_cwd = os.getcwd(),
  293. outdir = None,
  294. prefix = '',
  295. python = '"%s"' % sys.executable,
  296. redirect = redirect_to_file,
  297. scons = None,
  298. scons_flags = '--debug=count --debug=memory --debug=time --debug=memoizer',
  299. scons_lib_dir = None,
  300. scons_wrapper = None,
  301. startup_targets = '--help',
  302. subdir = None,
  303. subversion_url = None,
  304. svn = 'svn',
  305. svn_co_flag = '-q',
  306. tar = 'tar',
  307. targets = '',
  308. targets0 = None,
  309. targets1 = None,
  310. targets2 = None,
  311. title = None,
  312. unzip = 'unzip',
  313. verbose = False,
  314. vertical_bars = [],
  315. unpack_map = {
  316. '.tar.gz' : (untar, '%(tar)s xzf %%s'),
  317. '.tgz' : (untar, '%(tar)s xzf %%s'),
  318. '.tar' : (untar, '%(tar)s xf %%s'),
  319. '.zip' : (unzip, '%(unzip)s %%s'),
  320. },
  321. )
  322. run_titles = [
  323. 'Startup',
  324. 'Full build',
  325. 'Up-to-date build',
  326. ]
  327. run_commands = [
  328. '%(python)s %(scons_wrapper)s %(scons_flags)s --profile=%(prof0)s %(targets0)s',
  329. '%(python)s %(scons_wrapper)s %(scons_flags)s --profile=%(prof1)s %(targets1)s',
  330. '%(python)s %(scons_wrapper)s %(scons_flags)s --profile=%(prof2)s %(targets2)s',
  331. ]
  332. stages = [
  333. 'pre-read',
  334. 'post-read',
  335. 'pre-build',
  336. 'post-build',
  337. ]
  338. stage_strings = {
  339. 'pre-read' : 'Memory before reading SConscript files:',
  340. 'post-read' : 'Memory after reading SConscript files:',
  341. 'pre-build' : 'Memory before building targets:',
  342. 'post-build' : 'Memory after building targets:',
  343. }
  344. memory_string_all = 'Memory '
  345. default_stage = stages[-1]
  346. time_strings = {
  347. 'total' : 'Total build time',
  348. 'SConscripts' : 'Total SConscript file execution time',
  349. 'SCons' : 'Total SCons execution time',
  350. 'commands' : 'Total command execution time',
  351. }
  352. time_string_all = 'Total .* time'
  353. #
  354. def __init__(self):
  355. self.__dict__.update(self.default_settings)
  356. # Functions for displaying and executing commands.
  357. def subst(self, x, dictionary):
  358. try:
  359. return x % dictionary
  360. except TypeError:
  361. # x isn't a string (it's probably a Python function),
  362. # so just return it.
  363. return x
  364. def subst_variables(self, command, dictionary):
  365. """
  366. Substitutes (via the format operator) the values in the specified
  367. dictionary into the specified command.
  368. The command can be an (action, string) tuple. In all cases, we
  369. perform substitution on strings and don't worry if something isn't
  370. a string. (It's probably a Python function to be executed.)
  371. """
  372. try:
  373. command + ''
  374. except TypeError:
  375. action = command[0]
  376. string = command[1]
  377. args = command[2:]
  378. else:
  379. action = command
  380. string = action
  381. args = (())
  382. action = self.subst(action, dictionary)
  383. string = self.subst(string, dictionary)
  384. return (action, string, args)
  385. def _do_not_display(self, msg, *args):
  386. pass
  387. def display(self, msg, *args):
  388. """
  389. Displays the specified message.
  390. Each message is prepended with a standard prefix of our name
  391. plus the time.
  392. """
  393. if callable(msg):
  394. msg = msg(*args)
  395. else:
  396. msg = msg % args
  397. if msg is None:
  398. return
  399. fmt = '%s[%s]: %s\n'
  400. sys.stdout.write(fmt % (self.name, time.strftime('%H:%M:%S'), msg))
  401. def _do_not_execute(self, action, *args):
  402. pass
  403. def execute(self, action, *args):
  404. """
  405. Executes the specified action.
  406. The action is called if it's a callable Python function, and
  407. otherwise passed to os.system().
  408. """
  409. if callable(action):
  410. action(*args)
  411. else:
  412. os.system(action % args)
  413. def run_command_list(self, commands, dict):
  414. """
  415. Executes a list of commands, substituting values from the
  416. specified dictionary.
  417. """
  418. commands = [ self.subst_variables(c, dict) for c in commands ]
  419. for action, string, args in commands:
  420. self.display(string, *args)
  421. sys.stdout.flush()
  422. status = self.execute(action, *args)
  423. if status:
  424. sys.exit(status)
  425. def log_display(self, command, log):
  426. command = self.subst(command, self.__dict__)
  427. if log:
  428. command = self.redirect(command, log)
  429. return command
  430. def log_execute(self, command, log):
  431. command = self.subst(command, self.__dict__)
  432. output = os.popen(command).read()
  433. if self.verbose:
  434. sys.stdout.write(output)
  435. open(log, 'wb').write(output)
  436. #
  437. def archive_splitext(self, path):
  438. """
  439. Splits an archive name into a filename base and extension.
  440. This is like os.path.splitext() (which it calls) except that it
  441. also looks for '.tar.gz' and treats it as an atomic extensions.
  442. """
  443. if path.endswith('.tar.gz'):
  444. return path[:-7], path[-7:]
  445. else:
  446. return os.path.splitext(path)
  447. def args_to_files(self, args, tail=None):
  448. """
  449. Takes a list of arguments, expands any glob patterns, and
  450. returns the last "tail" files from the list.
  451. """
  452. files = []
  453. for a in args:
  454. files.extend(sorted(glob.glob(a)))
  455. if tail:
  456. files = files[-tail:]
  457. return files
  458. def ascii_table(self, files, columns,
  459. line_function, file_function=lambda x: x,
  460. *args, **kw):
  461. header_fmt = ' '.join(['%12s'] * len(columns))
  462. line_fmt = header_fmt + ' %s'
  463. print header_fmt % columns
  464. for file in files:
  465. t = line_function(file, *args, **kw)
  466. if t is None:
  467. t = []
  468. diff = len(columns) - len(t)
  469. if diff > 0:
  470. t += [''] * diff
  471. t.append(file_function(file))
  472. print line_fmt % tuple(t)
  473. def collect_results(self, files, function, *args, **kw):
  474. results = {}
  475. for file in files:
  476. base = os.path.splitext(file)[0]
  477. run, index = base.split('-')[-2:]
  478. run = int(run)
  479. index = int(index)
  480. value = function(file, *args, **kw)
  481. try:
  482. r = results[index]
  483. except KeyError:
  484. r = []
  485. results[index] = r
  486. r.append((run, value))
  487. return results
  488. def doc_to_help(self, obj):
  489. """
  490. Translates an object's __doc__ string into help text.
  491. This strips a consistent number of spaces from each line in the
  492. help text, essentially "outdenting" the text to the left-most
  493. column.
  494. """
  495. doc = obj.__doc__
  496. if doc is None:
  497. return ''
  498. return self.outdent(doc)
  499. def find_next_run_number(self, dir, prefix):
  500. """
  501. Returns the next run number in a directory for the specified prefix.
  502. Examines the contents the specified directory for files with the
  503. specified prefix, extracts the run numbers from each file name,
  504. and returns the next run number after the largest it finds.
  505. """
  506. x = re.compile(re.escape(prefix) + '-([0-9]+).*')
  507. matches = [x.match(e) for e in os.listdir(dir)]
  508. matches = [_f for _f in matches if _f]
  509. if not matches:
  510. return 0
  511. run_numbers = [int(m.group(1)) for m in matches]
  512. return int(max(run_numbers)) + 1
  513. def gnuplot_results(self, results, fmt='%s %.3f'):
  514. """
  515. Prints out a set of results in Gnuplot format.
  516. """
  517. gp = Gnuplotter(self.title, self.key_location)
  518. for i in sorted(results.keys()):
  519. try:
  520. t = self.run_titles[i]
  521. except IndexError:
  522. t = '??? %s ???' % i
  523. results[i].sort()
  524. gp.line(results[i], i+1, t, None, t, fmt=fmt)
  525. for bar_tuple in self.vertical_bars:
  526. try:
  527. x, type, label, comment = bar_tuple
  528. except ValueError:
  529. x, type, label = bar_tuple
  530. comment = label
  531. gp.vertical_bar(x, type, label, comment)
  532. gp.draw()
  533. def logfile_name(self, invocation):
  534. """
  535. Returns the absolute path of a log file for the specificed
  536. invocation number.
  537. """
  538. name = self.prefix_run + '-%d.log' % invocation
  539. return os.path.join(self.outdir, name)
  540. def outdent(self, s):
  541. """
  542. Strip as many spaces from each line as are found at the beginning
  543. of the first line in the list.
  544. """
  545. lines = s.split('\n')
  546. if lines[0] == '':
  547. lines = lines[1:]
  548. spaces = re.match(' *', lines[0]).group(0)
  549. def strip_initial_spaces(l, s=spaces):
  550. if l.startswith(spaces):
  551. l = l[len(spaces):]
  552. return l
  553. return '\n'.join([ strip_initial_spaces(l) for l in lines ]) + '\n'
  554. def profile_name(self, invocation):
  555. """
  556. Returns the absolute path of a profile file for the specified
  557. invocation number.
  558. """
  559. name = self.prefix_run + '-%d.prof' % invocation
  560. return os.path.join(self.outdir, name)
  561. def set_env(self, key, value):
  562. os.environ[key] = value
  563. #
  564. def get_debug_times(self, file, time_string=None):
  565. """
  566. Fetch times from the --debug=time strings in the specified file.
  567. """
  568. if time_string is None:
  569. search_string = self.time_string_all
  570. else:
  571. search_string = time_string
  572. contents = open(file).read()
  573. if not contents:
  574. sys.stderr.write('file %s has no contents!\n' % repr(file))
  575. return None
  576. result = re.findall(r'%s: ([\d\.]*)' % search_string, contents)[-4:]
  577. result = [ float(r) for r in result ]
  578. if not time_string is None:
  579. try:
  580. result = result[0]
  581. except IndexError:
  582. sys.stderr.write('file %s has no results!\n' % repr(file))
  583. return None
  584. return result
  585. def get_function_profile(self, file, function):
  586. """
  587. Returns the file, line number, function name, and cumulative time.
  588. """
  589. try:
  590. import pstats
  591. except ImportError, e:
  592. sys.stderr.write('%s: func: %s\n' % (self.name, e))
  593. sys.stderr.write('%s This version of Python is missing the profiler.\n' % self.name_spaces)
  594. sys.stderr.write('%s Cannot use the "func" subcommand.\n' % self.name_spaces)
  595. sys.exit(1)
  596. statistics = pstats.Stats(file).stats
  597. matches = [ e for e in statistics.items() if e[0][2] == function ]
  598. r = matches[0]
  599. return r[0][0], r[0][1], r[0][2], r[1][3]
  600. def get_function_time(self, file, function):
  601. """
  602. Returns just the cumulative time for the specified function.
  603. """
  604. return self.get_function_profile(file, function)[3]
  605. def get_memory(self, file, memory_string=None):
  606. """
  607. Returns a list of integers of the amount of memory used. The
  608. default behavior is to return all the stages.
  609. """
  610. if memory_string is None:
  611. search_string = self.memory_string_all
  612. else:
  613. search_string = memory_string
  614. lines = open(file).readlines()
  615. lines = [ l for l in lines if l.startswith(search_string) ][-4:]
  616. result = [ int(l.split()[-1]) for l in lines[-4:] ]
  617. if len(result) == 1:
  618. result = result[0]
  619. return result
  620. def get_object_counts(self, file, object_name, index=None):
  621. """
  622. Returns the counts of the specified object_name.
  623. """
  624. object_string = ' ' + object_name + '\n'
  625. lines = open(file).readlines()
  626. line = [ l for l in lines if l.endswith(object_string) ][0]
  627. result = [ int(field) for field in line.split()[:4] ]
  628. if index is not None:
  629. result = result[index]
  630. return result
  631. #
  632. command_alias = {}
  633. def execute_subcommand(self, argv):
  634. """
  635. Executes the do_*() function for the specified subcommand (argv[0]).
  636. """
  637. if not argv:
  638. return
  639. cmdName = self.command_alias.get(argv[0], argv[0])
  640. try:
  641. func = getattr(self, 'do_' + cmdName)
  642. except AttributeError:
  643. return self.default(argv)
  644. try:
  645. return func(argv)
  646. except TypeError, e:
  647. sys.stderr.write("%s %s: %s\n" % (self.name, cmdName, e))
  648. import traceback
  649. traceback.print_exc(file=sys.stderr)
  650. sys.stderr.write("Try '%s help %s'\n" % (self.name, cmdName))
  651. def default(self, argv):
  652. """
  653. The default behavior for an unknown subcommand. Prints an
  654. error message and exits.
  655. """
  656. sys.stderr.write('%s: Unknown subcommand "%s".\n' % (self.name, argv[0]))
  657. sys.stderr.write('Type "%s help" for usage.\n' % self.name)
  658. sys.exit(1)
  659. #
  660. def do_help(self, argv):
  661. """
  662. """
  663. if argv[1:]:
  664. for arg in argv[1:]:
  665. try:
  666. func = getattr(self, 'do_' + arg)
  667. except AttributeError:
  668. sys.stderr.write('%s: No help for "%s"\n' % (self.name, arg))
  669. else:
  670. try:
  671. help = getattr(self, 'help_' + arg)
  672. except AttributeError:
  673. sys.stdout.write(self.doc_to_help(func))
  674. sys.stdout.flush()
  675. else:
  676. help()
  677. else:
  678. doc = self.doc_to_help(self.__class__)
  679. if doc:
  680. sys.stdout.write(doc)
  681. sys.stdout.flush()
  682. return None
  683. #
  684. def help_func(self):
  685. help = """\
  686. Usage: scons-time func [OPTIONS] FILE [...]
  687. -C DIR, --chdir=DIR Change to DIR before looking for files
  688. -f FILE, --file=FILE Read configuration from specified FILE
  689. --fmt=FORMAT, --format=FORMAT Print data in specified FORMAT
  690. --func=NAME, --function=NAME Report time for function NAME
  691. -h, --help Print this help and exit
  692. -p STRING, --prefix=STRING Use STRING as log file/profile prefix
  693. -t NUMBER, --tail=NUMBER Only report the last NUMBER files
  694. --title=TITLE Specify the output plot TITLE
  695. """
  696. sys.stdout.write(self.outdent(help))
  697. sys.stdout.flush()
  698. def do_func(self, argv):
  699. """
  700. """
  701. format = 'ascii'
  702. function_name = '_main'
  703. tail = None
  704. short_opts = '?C:f:hp:t:'
  705. long_opts = [
  706. 'chdir=',
  707. 'file=',
  708. 'fmt=',
  709. 'format=',
  710. 'func=',
  711. 'function=',
  712. 'help',
  713. 'prefix=',
  714. 'tail=',
  715. 'title=',
  716. ]
  717. opts, args = getopt.getopt(argv[1:], short_opts, long_opts)
  718. for o, a in opts:
  719. if o in ('-C', '--chdir'):
  720. self.chdir = a
  721. elif o in ('-f', '--file'):
  722. self.config_file = a
  723. elif o in ('--fmt', '--format'):
  724. format = a
  725. elif o in ('--func', '--function'):
  726. function_name = a
  727. elif o in ('-?', '-h', '--help'):
  728. self.do_help(['help', 'func'])
  729. sys.exit(0)
  730. elif o in ('--max',):
  731. max_time = int(a)
  732. elif o in ('-p', '--prefix'):
  733. self.prefix = a
  734. elif o in ('-t', '--tail'):
  735. tail = int(a)
  736. elif o in ('--title',):
  737. self.title = a
  738. if self.config_file:
  739. exec open(self.config_file, 'rU').read() in self.__dict__
  740. if self.chdir:
  741. os.chdir(self.chdir)
  742. if not args:
  743. pattern = '%s*.prof' % self.prefix
  744. args = self.args_to_files([pattern], tail)
  745. if not args:
  746. if self.chdir:
  747. directory = self.chdir
  748. else:
  749. directory = os.getcwd()
  750. sys.stderr.write('%s: func: No arguments specified.\n' % self.name)
  751. sys.stderr.write('%s No %s*.prof files found in "%s".\n' % (self.name_spaces, self.prefix, directory))
  752. sys.stderr.write('%s Type "%s help func" for help.\n' % (self.name_spaces, self.name))
  753. sys.exit(1)
  754. else:
  755. args = self.args_to_files(args, tail)
  756. cwd_ = os.getcwd() + os.sep
  757. if format == 'ascii':
  758. for file in args:
  759. try:
  760. f, line, func, time = \
  761. self.get_function_profile(file, function_name)
  762. except ValueError, e:
  763. sys.stderr.write("%s: func: %s: %s\n" %
  764. (self.name, file, e))
  765. else:
  766. if f.startswith(cwd_):
  767. f = f[len(cwd_):]
  768. print "%.3f %s:%d(%s)" % (time, f, line, func)
  769. elif format == 'gnuplot':
  770. results = self.collect_results(args, self.get_function_time,
  771. function_name)
  772. self.gnuplot_results(results)
  773. else:
  774. sys.stderr.write('%s: func: Unknown format "%s".\n' % (self.name, format))
  775. sys.exit(1)
  776. #
  777. def help_mem(self):
  778. help = """\
  779. Usage: scons-time mem [OPTIONS] FILE [...]
  780. -C DIR, --chdir=DIR Change to DIR before looking for files
  781. -f FILE, --file=FILE Read configuration from specified FILE
  782. --fmt=FORMAT, --format=FORMAT Print data in specified FORMAT
  783. -h, --help Print this help and exit
  784. -p STRING, --prefix=STRING Use STRING as log file/profile prefix
  785. --stage=STAGE Plot memory at the specified stage:
  786. pre-read, post-read, pre-build,
  787. post-build (default: post-build)
  788. -t NUMBER, --tail=NUMBER Only report the last NUMBER files
  789. --title=TITLE Specify the output plot TITLE
  790. """
  791. sys.stdout.write(self.outdent(help))
  792. sys.stdout.flush()
  793. def do_mem(self, argv):
  794. format = 'ascii'
  795. logfile_path = lambda x: x
  796. stage = self.default_stage
  797. tail = None
  798. short_opts = '?C:f:hp:t:'
  799. long_opts = [
  800. 'chdir=',
  801. 'file=',
  802. 'fmt=',
  803. 'format=',
  804. 'help',
  805. 'prefix=',
  806. 'stage=',
  807. 'tail=',
  808. 'title=',
  809. ]
  810. opts, args = getopt.getopt(argv[1:], short_opts, long_opts)
  811. for o, a in opts:
  812. if o in ('-C', '--chdir'):
  813. self.chdir = a
  814. elif o in ('-f', '--file'):
  815. self.config_file = a
  816. elif o in ('--fmt', '--format'):
  817. format = a
  818. elif o in ('-?', '-h', '--help'):
  819. self.do_help(['help', 'mem'])
  820. sys.exit(0)
  821. elif o in ('-p', '--prefix'):
  822. self.prefix = a
  823. elif o in ('--stage',):
  824. if not a in self.stages:
  825. sys.stderr.write('%s: mem: Unrecognized stage "%s".\n' % (self.name, a))
  826. sys.exit(1)
  827. stage = a
  828. elif o in ('-t', '--tail'):
  829. tail = int(a)
  830. elif o in ('--title',):
  831. self.title = a
  832. if self.config_file:
  833. HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
  834. if self.chdir:
  835. os.chdir(self.chdir)
  836. logfile_path = lambda x: os.path.join(self.chdir, x)
  837. if not args:
  838. pattern = '%s*.log' % self.prefix
  839. args = self.args_to_files([pattern], tail)
  840. if not args:
  841. if self.chdir:
  842. directory = self.chdir
  843. else:
  844. directory = os.getcwd()
  845. sys.stderr.write('%s: mem: No arguments specified.\n' % self.name)
  846. sys.stderr.write('%s No %s*.log files found in "%s".\n' % (self.name_spaces, self.prefix, directory))
  847. sys.stderr.write('%s Type "%s help mem" for help.\n' % (self.name_spaces, self.name))
  848. sys.exit(1)
  849. else:
  850. args = self.args_to_files(args, tail)
  851. cwd_ = os.getcwd() + os.sep
  852. if format == 'ascii':
  853. self.ascii_table(args, tuple(self.stages), self.get_memory, logfile_path)
  854. elif format == 'gnuplot':
  855. results = self.collect_results(args, self.get_memory,
  856. self.stage_strings[stage])
  857. self.gnuplot_results(results)
  858. else:
  859. sys.stderr.write('%s: mem: Unknown format "%s".\n' % (self.name, format))
  860. sys.exit(1)
  861. return 0
  862. #
  863. def help_obj(self):
  864. help = """\
  865. Usage: scons-time obj [OPTIONS] OBJECT FILE [...]
  866. -C DIR, --chdir=DIR Change to DIR before looking for files
  867. -f FILE, --file=FILE Read configuration from specified FILE
  868. --fmt=FORMAT, --format=FORMAT Print data in specified FORMAT
  869. -h, --help Print this help and exit
  870. -p STRING, --prefix=STRING Use STRING as log file/profile prefix
  871. --stage=STAGE Plot memory at the specified stage:
  872. pre-read, post-read, pre-build,
  873. post-build (default: post-build)
  874. -t NUMBER, --tail=NUMBER Only report the last NUMBER files
  875. --title=TITLE Specify the output plot TITLE
  876. """
  877. sys.stdout.write(self.outdent(help))
  878. sys.stdout.flush()
  879. def do_obj(self, argv):
  880. format = 'ascii'
  881. logfile_path = lambda x: x
  882. stage = self.default_stage
  883. tail = None
  884. short_opts = '?C:f:hp:t:'
  885. long_opts = [
  886. 'chdir=',
  887. 'file=',
  888. 'fmt=',
  889. 'format=',
  890. 'help',
  891. 'prefix=',
  892. 'stage=',
  893. 'tail=',
  894. 'title=',
  895. ]
  896. opts, args = getopt.getopt(argv[1:], short_opts, long_opts)
  897. for o, a in opts:
  898. if o in ('-C', '--chdir'):
  899. self.chdir = a
  900. elif o in ('-f', '--file'):
  901. self.config_file = a
  902. elif o in ('--fmt', '--format'):
  903. format = a
  904. elif o in ('-?', '-h', '--help'):
  905. self.do_help(['help', 'obj'])
  906. sys.exit(0)
  907. elif o in ('-p', '--prefix'):
  908. self.prefix = a
  909. elif o in ('--stage',):
  910. if not a in self.stages:
  911. sys.stderr.write('%s: obj: Unrecognized stage "%s".\n' % (self.name, a))
  912. sys.stderr.write('%s Type "%s help obj" for help.\n' % (self.name_spaces, self.name))
  913. sys.exit(1)
  914. stage = a
  915. elif o in ('-t', '--tail'):
  916. tail = int(a)
  917. elif o in ('--title',):
  918. self.title = a
  919. if not args:
  920. sys.stderr.write('%s: obj: Must specify an object name.\n' % self.name)
  921. sys.stderr.write('%s Type "%s help obj" for help.\n' % (self.name_spaces, self.name))
  922. sys.exit(1)
  923. object_name = args.pop(0)
  924. if self.config_file:
  925. HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
  926. if self.chdir:
  927. os.chdir(self.chdir)
  928. logfile_path = lambda x: os.path.join(self.chdir, x)
  929. if not args:
  930. pattern = '%s*.log' % self.prefix
  931. args = self.args_to_files([pattern], tail)
  932. if not args:
  933. if self.chdir:
  934. directory = self.chdir
  935. else:
  936. directory = os.getcwd()
  937. sys.stderr.write('%s: obj: No arguments specified.\n' % self.name)
  938. sys.stderr.write('%s No %s*.log files found in "%s".\n' % (self.name_spaces, self.prefix, directory))
  939. sys.stderr.write('%s Type "%s help obj" for help.\n' % (self.name_spaces, self.name))
  940. sys.exit(1)
  941. else:
  942. args = self.args_to_files(args, tail)
  943. cwd_ = os.getcwd() + os.sep
  944. if format == 'ascii':
  945. self.ascii_table(args, tuple(self.stages), self.get_object_counts, logfile_path, object_name)
  946. elif format == 'gnuplot':
  947. stage_index = 0
  948. for s in self.stages:
  949. if stage == s:
  950. break
  951. stage_index = stage_index + 1
  952. results = self.collect_results(args, self.get_object_counts,
  953. object_name, stage_index)
  954. self.gnuplot_results(results)
  955. else:
  956. sys.stderr.write('%s: obj: Unknown format "%s".\n' % (self.name, format))
  957. sys.exit(1)
  958. return 0
  959. #
  960. def help_run(self):
  961. help = """\
  962. Usage: scons-time run [OPTIONS] [FILE ...]
  963. --aegis=PROJECT Use SCons from the Aegis PROJECT
  964. --chdir=DIR Name of unpacked directory for chdir
  965. -f FILE, --file=FILE Read configuration from specified FILE
  966. -h, --help Print this help and exit
  967. -n, --no-exec No execute, just print command lines
  968. --number=NUMBER Put output in files for run NUMBER
  969. --outdir=OUTDIR Put output files in OUTDIR
  970. -p STRING, --prefix=STRING Use STRING as log file/profile prefix
  971. --python=PYTHON Time using the specified PYTHON
  972. -q, --quiet Don't print command lines
  973. --scons=SCONS Time using the specified SCONS
  974. --svn=URL, --subversion=URL Use SCons from Subversion URL
  975. -v, --verbose Display output of commands
  976. """
  977. sys.stdout.write(self.outdent(help))
  978. sys.stdout.flush()
  979. def do_run(self, argv):
  980. """
  981. """
  982. run_number_list = [None]
  983. short_opts = '?f:hnp:qs:v'
  984. long_opts = [
  985. 'aegis=',
  986. 'file=',
  987. 'help',
  988. 'no-exec',
  989. 'number=',
  990. 'outdir=',
  991. 'prefix=',
  992. 'python=',
  993. 'quiet',
  994. 'scons=',
  995. 'svn=',
  996. 'subdir=',
  997. 'subversion=',
  998. 'verbose',
  999. ]
  1000. opts, args = getopt.getopt(argv[1:], short_opts, long_opts)
  1001. for o, a in opts:
  1002. if o in ('--aegis',):
  1003. self.aegis_project = a
  1004. elif o in ('-f', '--file'):
  1005. self.config_file = a
  1006. elif o in ('-?', '-h', '--help'):
  1007. self.do_help(['help', 'run'])
  1008. sys.exit(0)
  1009. elif o in ('-n', '--no-exec'):
  1010. self.execute = self._do_not_execute
  1011. elif o in ('--number',):
  1012. run_number_list = self.split_run_numbers(a)
  1013. elif o in ('--outdir',):
  1014. self.outdir = a
  1015. elif o in ('-p', '--prefix'):
  1016. self.prefix = a
  1017. elif o in ('--python',):
  1018. self.python = a
  1019. elif o in ('-q', '--quiet'):
  1020. self.display = self._do_not_display
  1021. elif o in ('-s', '--subdir'):
  1022. self.subdir = a
  1023. elif o in ('--scons',):
  1024. self.scons = a
  1025. elif o in ('--svn', '--subversion'):
  1026. self.subversion_url = a
  1027. elif o in ('-v', '--verbose'):
  1028. self.redirect = tee_to_file
  1029. self.verbose = True
  1030. self.svn_co_flag = ''
  1031. if not args and not self.config_file:
  1032. sys.stderr.write('%s: run: No arguments or -f config file specified.\n' % self.name)
  1033. sys.stderr.write('%s Type "%s help run" for help.\n' % (self.name_spaces, self.name))
  1034. sys.exit(1)
  1035. if self.config_file:
  1036. exec open(self.config_file, 'rU').read() in self.__dict__
  1037. if args:
  1038. self.archive_list = args
  1039. archive_file_name = os.path.split(self.archive_list[0])[1]
  1040. if not self.subdir:
  1041. self.subdir = self.archive_splitext(archive_file_name)[0]
  1042. if not self.prefix:
  1043. self.prefix = self.archive_splitext(archive_file_name)[0]
  1044. prepare = None
  1045. if self.subversion_url:
  1046. prepare = self.prep_subversion_run
  1047. elif self.aegis_project:
  1048. prepare = self.prep_aegis_run
  1049. for run_number in run_number_list:
  1050. self.individual_run(run_number, self.archive_list, prepare)
  1051. def split_run_numbers(self, s):
  1052. result = []
  1053. for n in s.split(','):
  1054. try:
  1055. x, y = n.split('-')
  1056. except ValueError:
  1057. result.append(int(n))
  1058. else:
  1059. result.extend(list(range(int(x), int(y)+1)))
  1060. return result
  1061. def scons_path(self, dir):
  1062. return os.path.join(dir, 'src', 'script', 'scons.py')
  1063. def scons_lib_dir_path(self, dir):
  1064. return os.path.join(dir, 'src', 'engine')
  1065. def prep_aegis_run(self, commands, removals):
  1066. self.aegis_tmpdir = make_temp_file(prefix = self.name + '-aegis-')
  1067. removals.append((shutil.rmtree, 'rm -rf %%s', self.aegis_tmpdir))
  1068. self.aegis_parent_project = os.path.splitext(self.aegis_project)[0]
  1069. self.scons = self.scons_path(self.aegis_tmpdir)
  1070. self.scons_lib_dir = self.scons_lib_dir_path(self.aegis_tmpdir)
  1071. commands.extend([
  1072. 'mkdir %(aegis_tmpdir)s',
  1073. (lambda: os.chdir(self.aegis_tmpdir), 'cd %(aegis_tmpdir)s'),
  1074. '%(aegis)s -cp -ind -p %(aegis_parent_project)s .',
  1075. '%(aegis)s -cp -ind -p %(aegis_project)s -delta %(run_number)s .',
  1076. ])
  1077. def prep_subversion_run(self, commands, removals):
  1078. self.svn_tmpdir = make_temp_file(prefix = self.name + '-svn-')
  1079. removals.append((shutil.rmtree, 'rm -rf %%s', self.svn_tmpdir))
  1080. self.scons = self.scons_path(self.svn_tmpdir)
  1081. self.scons_lib_dir = self.scons_lib_dir_path(self.svn_tmpdir)
  1082. commands.extend([
  1083. 'mkdir %(svn_tmpdir)s',
  1084. '%(svn)s co %(svn_co_flag)s -r %(run_number)s %(subversion_url)s %(svn_tmpdir)s',
  1085. ])
  1086. def individual_run(self, run_number, archive_list, prepare=None):
  1087. """
  1088. Performs an individual run of the default SCons invocations.
  1089. """
  1090. commands = []
  1091. removals = []
  1092. if prepare:
  1093. prepare(commands, removals)
  1094. save_scons = self.scons
  1095. save_scons_wrapper = self.scons_wrapper
  1096. save_scons_lib_dir = self.scons_lib_dir
  1097. if self.outdir is None:
  1098. self.outdir = self.orig_cwd
  1099. elif not os.path.isabs(self.outdir):
  1100. self.outdir = os.path.join(self.orig_cwd, self.outdir)
  1101. if self.scons is None:
  1102. self.scons = self.scons_path(self.orig_cwd)
  1103. if self.scons_lib_dir is None:
  1104. self.scons_lib_dir = self.scons_lib_dir_path(self.orig_cwd)
  1105. if self.scons_wrapper is None:
  1106. self.scons_wrapper = self.scons
  1107. if not run_number:
  1108. run_number = self.find_next_run_number(self.outdir, self.prefix)
  1109. self.run_number = str(run_number)
  1110. self.prefix_run = self.prefix + '-%03d' % run_number
  1111. if self.targets0 is None:
  1112. self.targets0 = self.startup_targets
  1113. if self.targets1 is None:
  1114. self.targets1 = self.targets
  1115. if self.targets2 is None:
  1116. self.targets2 = self.targets
  1117. self.tmpdir = make_temp_file(prefix = self.name + '-')
  1118. commands.extend([
  1119. 'mkdir %(tmpdir)s',
  1120. (os.chdir, 'cd %%s', self.tmpdir),
  1121. ])
  1122. for archive in archive_list:
  1123. if not os.path.isabs(archive):
  1124. archive = os.path.join(self.orig_cwd, archive)
  1125. if os.path.isdir(archive):
  1126. dest = os.path.split(archive)[1]
  1127. commands.append((shutil.copytree, 'cp -r %%s %%s', archive, dest))
  1128. else:
  1129. suffix = self.archive_splitext(archive)[1]
  1130. unpack_command = self.unpack_map.get(suffix)
  1131. if not unpack_command:
  1132. dest = os.path.split(archive)[1]
  1133. commands.append((shutil.copyfile, 'cp %%s %%s', archive, dest))
  1134. else:
  1135. commands.append(unpack_command + (archive,))
  1136. commands.extend([
  1137. (os.chdir, 'cd %%s', self.subdir),
  1138. ])
  1139. commands.extend(self.initial_commands)
  1140. commands.extend([
  1141. (lambda: read_tree('.'),
  1142. 'find * -type f | xargs cat > /dev/null'),
  1143. (self.set_env, 'export %%s=%%s',
  1144. 'SCONS_LIB_DIR', self.scons_lib_dir),
  1145. '%(python)s %(scons_wrapper)s --version',
  1146. ])
  1147. index = 0
  1148. for run_command in self.run_commands:
  1149. setattr(self, 'prof%d' % index, self.profile_name(index))
  1150. c = (
  1151. self.log_execute,
  1152. self.log_display,
  1153. run_command,
  1154. self.logfile_name(index),
  1155. )
  1156. commands.append(c)
  1157. index = index + 1
  1158. commands.extend([
  1159. (os.chdir, 'cd %%s', self.orig_cwd),
  1160. ])
  1161. if not os.environ.get('PRESERVE'):
  1162. commands.extend(removals)
  1163. commands.append((shutil.rmtree, 'rm -rf %%s', self.tmpdir))
  1164. self.run_command_list(commands, self.__dict__)
  1165. self.scons = save_scons
  1166. self.scons_lib_dir = save_scons_lib_dir
  1167. self.scons_wrapper = save_scons_wrapper
  1168. #
  1169. def help_time(self):
  1170. help = """\
  1171. Usage: scons-time time [OPTIONS] FILE [...]
  1172. -C DIR, --chdir=DIR Change to DIR before looking for files
  1173. -f FILE, --file=FILE Read configuration from specified FILE
  1174. --fmt=FORMAT, --format=FORMAT Print data in specified FORMAT
  1175. -h, --help Print this help and exit
  1176. -p STRING, --prefix=STRING Use STRING as log file/profile prefix
  1177. -t NUMBER, --tail=NUMBER Only report the last NUMBER files
  1178. --which=TIMER Plot timings for TIMER: total,
  1179. SConscripts, SCons, commands.
  1180. """
  1181. sys.stdout.write(self.outdent(help))
  1182. sys.stdout.flush()
  1183. def do_time(self, argv):
  1184. format = 'ascii'
  1185. logfile_path = lambda x: x
  1186. tail = None
  1187. which = 'total'
  1188. short_opts = '?C:f:hp:t:'
  1189. long_opts = [
  1190. 'chdir=',
  1191. 'file=',
  1192. 'fmt=',
  1193. 'format=',
  1194. 'help',
  1195. 'prefix=',
  1196. 'tail=',
  1197. 'title=',
  1198. 'which=',
  1199. ]
  1200. opts, args = getopt.getopt(argv[1:], short_opts, long_opts)
  1201. for o, a in opts:
  1202. if o in ('-C', '--chdir'):
  1203. self.chdir = a
  1204. elif o in ('-f', '--file'):
  1205. self.config_file = a
  1206. elif o in ('--fmt', '--format'):
  1207. format = a
  1208. elif o in ('-?', '-h', '--help'):
  1209. self.do_help(['help', 'time'])
  1210. sys.exit(0)
  1211. elif o in ('-p', '--prefix'):
  1212. self.prefix = a
  1213. elif o in ('-t', '--tail'):
  1214. tail = int(a)
  1215. elif o in ('--title',):
  1216. self.title = a
  1217. elif o in ('--which',):
  1218. if not a in self.time_strings.keys():
  1219. sys.stderr.write('%s: time: Unrecognized timer "%s".\n' % (self.name, a))
  1220. sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name))
  1221. sys.exit(1)
  1222. which = a
  1223. if self.config_file:
  1224. HACK_for_exec(open(self.config_file, 'rU').read(), self.__dict__)
  1225. if self.chdir:
  1226. os.chdir(self.chdir)
  1227. logfile_path = lambda x: os.path.join(self.chdir, x)
  1228. if not args:
  1229. pattern = '%s*.log' % self.prefix
  1230. args = self.args_to_files([pattern], tail)
  1231. if not args:
  1232. if self.chdir:
  1233. directory = self.chdir
  1234. else:
  1235. directory = os.getcwd()
  1236. sys.stderr.write('%s: time: No arguments specified.\n' % self.name)
  1237. sys.stderr.write('%s No %s*.log files found in "%s".\n' % (self.name_spaces, self.prefix, directory))
  1238. sys.stderr.write('%s Type "%s help time" for help.\n' % (self.name_spaces, self.name))
  1239. sys.exit(1)
  1240. else:
  1241. args = self.args_to_files(args, tail)
  1242. cwd_ = os.getcwd() + os.sep
  1243. if format == 'ascii':
  1244. columns = ("Total", "SConscripts", "SCons", "commands")
  1245. self.ascii_table(args, columns, self.get_debug_times, logfile_path)
  1246. elif format == 'gnuplot':
  1247. results = self.collect_results(args, self.get_debug_times,
  1248. self.time_strings[which])
  1249. self.gnuplot_results(results, fmt='%s %.6f')
  1250. else:
  1251. sys.stderr.write('%s: time: Unknown format "%s".\n' % (self.name, format))
  1252. sys.exit(1)
  1253. if __name__ == '__main__':
  1254. opts, args = getopt.getopt(sys.argv[1:], 'h?V', ['help', 'version'])
  1255. ST = SConsTim

Large files files are truncated, but you can click here to view the full file