...
-Using RunSnake
---------------
-
-This option requires the `RunSnake <https://pypi.python.org/pypi/RunSnakeRun>`_
-command line tool be installed::
-
- $ python -m examples.performance single_inserts --test test_core --num 1000 --runsnake
-
-A graphical RunSnake output will be displayed.
.. _examples_profiling_writeyourown:
test_joinedload : load everything, joined eager loading. (1000 iterations); total time 2.754592 sec
test_subqueryload : load everything, subquery eager loading. (1000 iterations); total time 2.977696 sec
-As well as see RunSnake output for an individual test::
-
- $ python test_loads.py --num 100 --runsnake --test test_joinedload
""" # noqa
import argparse
def __init__(self, options):
self.test = options.test
self.dburl = options.dburl
- self.runsnake = options.runsnake
self.profile = options.profile
self.dump = options.dump
+ self.raw = options.raw
self.callers = options.callers
self.num = options.num
self.echo = options.echo
def _run_test(self, fn):
if self._setup:
self._setup(self.dburl, self.echo, self.num)
- if self.profile or self.runsnake or self.dump:
+ if self.profile or self.dump:
self._run_with_profile(fn, self.sort)
else:
self._run_with_time(fn)
help="dump full call profile (implies --profile)",
)
parser.add_argument(
- "--callers",
- action="store_true",
- help="print callers as well (implies --dump)",
+ "--raw",
+ type=str,
+ help="dump raw profile data to file (implies --profile)",
)
parser.add_argument(
- "--runsnake",
+ "--callers",
action="store_true",
- help="invoke runsnakerun (implies --profile)",
+ help="print callers as well (implies --dump)",
)
parser.add_argument(
"--echo", action="store_true", help="Echo SQL output"
args = parser.parse_args()
args.dump = args.dump or args.callers
- args.profile = args.profile or args.dump or args.runsnake
+ args.profile = args.profile or args.dump or args.raw
if cls.name is None:
__import__(__name__ + "." + args.name)
return summary
def report_stats(self):
- if self.profile.runsnake:
- self._runsnake()
- elif self.profile.dump:
+ if self.profile.dump:
self._dump(self.sort)
+ elif self.profile.raw:
+ self._dump_raw()
def _dump(self, sort):
self.stats.sort_stats(*re.split(r"[ ,]", self.sort))
if self.profile.callers:
self.stats.print_callers()
+ def _dump_raw(self):
+ self.stats.dump_stats(self.profile.raw)
+
def _runsnake(self):
filename = "%s.profile" % self.test.__name__
try: