Skip to content

Commit 6b3513f

Browse files
committed
Updates for examples / performance
Change-Id: I55fc60258075f6f3efb7f738b900f60b2d2994c4
1 parent 903b188 commit 6b3513f

2 files changed

Lines changed: 21 additions & 23 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. change::
2+
:tags: change, examples
3+
4+
Added new option ``--raw`` to the examples.performance suite
5+
which will dump the raw profile test for consumption by any
6+
number of profiling visualizer tools. Removed the "runsnake"
7+
option as runsnake is very hard to build at this point;

examples/performance/__init__.py

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,15 +107,6 @@
107107
108108
...
109109
110-
Using RunSnake
111-
--------------
112-
113-
This option requires the `RunSnake <https://pypi.python.org/pypi/RunSnakeRun>`_
114-
command line tool be installed::
115-
116-
$ python -m examples.performance single_inserts --test test_core --num 1000 --runsnake
117-
118-
A graphical RunSnake output will be displayed.
119110
120111
.. _examples_profiling_writeyourown:
121112
@@ -213,9 +204,6 @@ def test_subqueryload(n):
213204
test_joinedload : load everything, joined eager loading. (1000 iterations); total time 2.754592 sec
214205
test_subqueryload : load everything, subquery eager loading. (1000 iterations); total time 2.977696 sec
215206
216-
As well as see RunSnake output for an individual test::
217-
218-
$ python test_loads.py --num 100 --runsnake --test test_joinedload
219207
220208
""" # noqa
221209
import argparse
@@ -238,9 +226,9 @@ class Profiler(object):
238226
def __init__(self, options):
239227
self.test = options.test
240228
self.dburl = options.dburl
241-
self.runsnake = options.runsnake
242229
self.profile = options.profile
243230
self.dump = options.dump
231+
self.raw = options.raw
244232
self.callers = options.callers
245233
self.num = options.num
246234
self.echo = options.echo
@@ -317,7 +305,7 @@ def _run_with_time(self, fn):
317305
def _run_test(self, fn):
318306
if self._setup:
319307
self._setup(self.dburl, self.echo, self.num)
320-
if self.profile or self.runsnake or self.dump:
308+
if self.profile or self.dump:
321309
self._run_with_profile(fn, self.sort)
322310
else:
323311
self._run_with_time(fn)
@@ -371,22 +359,22 @@ def main(cls):
371359
help="dump full call profile (implies --profile)",
372360
)
373361
parser.add_argument(
374-
"--callers",
375-
action="store_true",
376-
help="print callers as well (implies --dump)",
362+
"--raw",
363+
type=str,
364+
help="dump raw profile data to file (implies --profile)",
377365
)
378366
parser.add_argument(
379-
"--runsnake",
367+
"--callers",
380368
action="store_true",
381-
help="invoke runsnakerun (implies --profile)",
369+
help="print callers as well (implies --dump)",
382370
)
383371
parser.add_argument(
384372
"--echo", action="store_true", help="Echo SQL output"
385373
)
386374
args = parser.parse_args()
387375

388376
args.dump = args.dump or args.callers
389-
args.profile = args.profile or args.dump or args.runsnake
377+
args.profile = args.profile or args.dump or args.raw
390378

391379
if cls.name is None:
392380
__import__(__name__ + "." + args.name)
@@ -431,17 +419,20 @@ def _summary(self):
431419
return summary
432420

433421
def report_stats(self):
434-
if self.profile.runsnake:
435-
self._runsnake()
436-
elif self.profile.dump:
422+
if self.profile.dump:
437423
self._dump(self.sort)
424+
elif self.profile.raw:
425+
self._dump_raw()
438426

439427
def _dump(self, sort):
440428
self.stats.sort_stats(*re.split(r"[ ,]", self.sort))
441429
self.stats.print_stats()
442430
if self.profile.callers:
443431
self.stats.print_callers()
444432

433+
def _dump_raw(self):
434+
self.stats.dump_stats(self.profile.raw)
435+
445436
def _runsnake(self):
446437
filename = "%s.profile" % self.test.__name__
447438
try:

0 commit comments

Comments
 (0)