Skip to content

Commit 4313b27

Browse files
committed
Change default profile options
Now `--profile(-compile)=<foo>` will set the filename and `--profile-kind=<foo>` will set whether it's an instrumented or heap profile.
1 parent f68c2ba commit 4313b27

File tree

2 files changed

+13
-10
lines changed

2 files changed

+13
-10
lines changed

src/HLL/Compiler.nqp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ class HLL::Compiler does HLL::Backend::Default {
2323
@!stages := nqp::split(' ', 'start parse ast ' ~ $!backend.stages());
2424

2525
# Command options and usage.
26-
@!cmdoptions := nqp::split(' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s source-name=s combine version|v show-config verbose-config|V stagestats=s? ll-exception rxtrace nqpevent=s profile=s? profile-compile=s? profile-filename=s profile-stage=s repl-mode=s'
26+
@!cmdoptions := nqp::split(' ', 'e=s help|h target=s trace|t=s encoding=s output|o=s source-name=s combine version|v show-config verbose-config|V stagestats=s? ll-exception rxtrace nqpevent=s profile=s? profile-compile=s? profile-kind=s profile-stage=s repl-mode=s'
2727
#?if js
2828
~ ' substagestats beautify nqp-runtime=s perl6-runtime=s libpath=s shebang execname=s source-map'
2929
#?endif
@@ -164,7 +164,7 @@ class HLL::Compiler does HLL::Backend::Default {
164164
if nqp::existskey(%adverbs, 'profile-compile') {
165165
$output := $!backend.run_profiled({
166166
self.compile($code, :compunit_ok(1), |%adverbs);
167-
}, %adverbs<profile-compile>, %adverbs<profile-filename>);
167+
}, %adverbs<profile-compile>, %adverbs<profile-kind>);
168168
}
169169
else {
170170
$output := self.compile($code, :compunit_ok(1), |%adverbs);
@@ -179,7 +179,7 @@ class HLL::Compiler does HLL::Backend::Default {
179179

180180
if nqp::existskey(%adverbs, 'profile') {
181181
$output := $!backend.run_profiled({ $output(|@args) },
182-
%adverbs<profile>, %adverbs<profile-filename>);
182+
%adverbs<profile>, %adverbs<profile-kind>);
183183
}
184184
elsif %adverbs<trace> {
185185
$output := $!backend.run_traced(%adverbs<trace>, { $output(|@args) });
@@ -488,7 +488,7 @@ class HLL::Compiler does HLL::Backend::Default {
488488
}
489489

490490
$result := %adverbs<profile-stage> eq $_
491-
?? $!backend.run_profiled(&run, '', %adverbs<profile-filename>)
491+
?? $!backend.run_profiled(&run, %adverbs<profile>, %adverbs<profile-kind>)
492492
!! run();
493493

494494
my $diff := nqp::time_n() - $timestamp;

src/vm/moar/HLL/Backend.nqp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,24 +58,27 @@ class HLL::Backend::MoarVM {
5858
)))));
5959
}
6060
}
61-
method run_profiled($what, $kind, $filename?) {
61+
method run_profiled($what, $filename, $kind) {
6262
$kind := 'instrumented' unless $kind;
6363

64-
my @END := nqp::gethllsym('perl6', '@END_PHASERS');
65-
@END.push(-> { self.dump_profile_data($prof_end_sub(), $kind, $filename) })
66-
if nqp::defined(@END);
67-
6864
self.ensure_prof_routines();
6965

7066
if $kind eq "heap" {
71-
unless nqp::defined($filename) {
67+
unless $filename {
7268
$filename := 'heap-snapshot-' ~ nqp::time_n();
7369
}
7470
$prof_start_sub(nqp::hash('kind', $kind, 'path', $filename));
7571
} else {
72+
unless $filename {
73+
$filename := 'profile-' ~ nqp::time_n() ~ '.html';
74+
}
7675
$prof_start_sub(nqp::hash('kind', $kind));
7776
}
7877

78+
my @END := nqp::gethllsym('perl6', '@END_PHASERS');
79+
@END.push(-> { self.dump_profile_data($prof_end_sub(), $kind, $filename) })
80+
if nqp::defined(@END);
81+
7982
my $res := $what();
8083
unless nqp::defined(@END) {
8184
my $data := $prof_end_sub();

0 commit comments

Comments
 (0)