Skip to content

Commit 3a5a36c

Browse files
committed
Fix default filename
Also move comment on output into option help
1 parent ce947e1 commit 3a5a36c

1 file changed

Lines changed: 5 additions & 13 deletions

File tree

mprof

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,10 @@ def run_action():
188188
parser.add_argument("--multiprocess", "-M", dest="multiprocess", action="store_true",
189189
help="""Monitors forked processes creating individual plots for each child (disables --python features)""")
190190
parser.add_argument("--output", "-o", dest="filename",
191-
default="mprofile_<YYYYMMDDhhmmss>.dat",
192-
help="""File to store results in, defaults to 'mprofile_<YYYYMMDDhhmmss>.dat',
193-
(where <YYYYMMDDhhmmss> is the date-time of the program start)""")
191+
default="mprofile_%s.dat" % time.strftime("%Y%m%d%H%M%S", time.localtime()),
192+
help="""File to store results in, defaults to 'mprofile_<YYYYMMDDhhmmss>.dat' in the current directory,
193+
(where <YYYYMMDDhhmmss> is the date-time of the program start).
194+
This file contains the process memory consumption, in Mb (one value per line).""")
194195
parser.add_argument("program", nargs=REMAINDER,
195196
help='Option 1: "<EXECUTABLE> <ARG1> <ARG2>..." - profile executable\n'
196197
'Option 2: "<PYTHON_SCRIPT> <ARG1> <ARG2>..." - profile python script\n'
@@ -206,16 +207,7 @@ def run_action():
206207
print("{1}: Sampling memory every {0}s".format(
207208
args.interval, osp.basename(sys.argv[0])))
208209

209-
if args.filename is None:
210-
## Output results in a file called "mprofile_<YYYYMMDDhhmmss>.dat" (where
211-
## <YYYYMMDDhhmmss> is the date-time of the program start) in the current
212-
## directory. This file contains the process memory consumption, in Mb (one
213-
## value per line). Memory is sampled twice each second."""
214-
215-
suffix = time.strftime("%Y%m%d%H%M%S", time.localtime())
216-
mprofile_output = "mprofile_%s.dat" % suffix
217-
else:
218-
mprofile_output = args.filename
210+
mprofile_output = args.filename
219211

220212
# .. TODO: more than one script as argument ? ..
221213
program = args.program

0 commit comments

Comments
 (0)