Skip to content

Commit 8a76674

Browse files
committed
Enable output to JSON and CLI
Signed-off-by: Garett Brown <garett.brown@xanadu.ai>
1 parent b11b287 commit 8a76674

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

scalene/scalene_profiler.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,7 @@ def cpu_signal_handler(
800800
@staticmethod
801801
def output_profile(program_args: Optional[List[str]] = None) -> bool:
802802
"""Output the profile. Returns true iff there was any info reported the profile."""
803+
did_output: bool = False
803804
if Scalene.__args.json:
804805
json_output = Scalene.__json.output_profiles(
805806
Scalene.__program_being_profiled,
@@ -837,9 +838,9 @@ def output_profile(program_args: Optional[List[str]] = None) -> bool:
837838
f.write(
838839
json.dumps(json_output, sort_keys=True, indent=4) + "\n"
839840
)
840-
return json_output != {}
841+
did_output = json_output != {}
841842

842-
else:
843+
if Scalene.__args.cli:
843844
output = Scalene.__output
844845
column_width = Scalene.__args.column_width
845846
if not Scalene.__args.html:
@@ -863,7 +864,7 @@ def output_profile(program_args: Optional[List[str]] = None) -> bool:
863864
profile_memory=Scalene.__args.memory,
864865
reduced_profile=Scalene.__args.reduced_profile,
865866
)
866-
return did_output
867+
return did_output
867868

868869
@staticmethod
869870
@functools.lru_cache(None)

0 commit comments

Comments
 (0)