Skip to content
Browse files

Add --profile option

  • Loading branch information...
1 parent b60bab9 commit 1c2bfa92cd8d6dddc75730f70b7522849f7db8ba @mmcgill mmcgill committed Oct 23, 2011
Showing with 8 additions and 1 deletion.
  1. +8 −1 mc3p/proxy.py
View
9 mc3p/proxy.py
@@ -32,6 +32,8 @@ def parse_args():
type="int", help="Listen on this port")
parser.add_option("--plugin", dest="plugins", metavar="ID:PLUGIN(ARGS)", type="string",
action="append", help="Configure a plugin", default=[])
+ parser.add_option("--profile", dest="perf_data", metavar="FILE", default=None,
+ help="Enable profiling, save profiling data to FILE")
(opts,args) = parser.parse_args()
if not 1 <= len(args) <= 2:
@@ -204,5 +206,10 @@ def parse_packet(stream, msg_spec, side):
MinecraftSession(pcfg, cli_sock, host, port)
# I/O event loop.
- asyncore.loop()
+ if opts.perf_data:
+ logger.warn("Profiling enabled, saving data to %s" % opts.perf_data)
+ import cProfile
+ cProfile.run('asyncore.loop()', opts.perf_data)
+ else:
+ asyncore.loop()

0 comments on commit 1c2bfa9

Please sign in to comment.
Something went wrong with that request. Please try again.