diff --git a/scalene/scalene_profiler.py b/scalene/scalene_profiler.py index 820ccc89b..2393d19ea 100644 --- a/scalene/scalene_profiler.py +++ b/scalene/scalene_profiler.py @@ -61,13 +61,7 @@ from typing import ( Any, Callable, - Dict, Generator, - List, - Optional, - Set, - Tuple, - Union, cast, ) @@ -104,7 +98,6 @@ add_stack, compute_frames_to_record, enter_function_meta, - flamegraph_format, generate_html, get_fully_qualified_name, on_stack, @@ -152,8 +145,6 @@ class Scalene: __last_profiled = [Filename("NADA"), LineNumber(0), ByteCodeIndex(0)] __orig_python = sys.executable # will be rewritten later - __last_profiled_invalidated = False - __gui_dir = "scalene-gui" __profile_filename = Filename("profile.json") __profiler_html = Filename("profile.html") __error_message = "Error in program being profiled" @@ -239,8 +230,6 @@ class Scalene: __last_cpu_interval = 0.0 - __done = False - def __init__( self, arguments: argparse.Namespace, @@ -370,7 +359,7 @@ def __init__( @staticmethod def last_profiled_tuple() -> tuple[Filename, LineNumber, ByteCodeIndex]: """Helper function to type last profiled information.""" - return cast(Tuple[Filename, LineNumber, ByteCodeIndex], Scalene.__last_profiled) + return cast(tuple[Filename, LineNumber, ByteCodeIndex], Scalene.__last_profiled) if sys.platform != "win32": __orig_setitimer = signal.setitimer @@ -593,7 +582,7 @@ def malloc_signal_handler( # If so, increment. invalidated = pywhere.get_last_profiled_invalidated() - (fname, lineno, lasti) = Scalene.last_profiled_tuple() + (fname, lineno, _lasti) = Scalene.last_profiled_tuple() if not invalidated and this_frame and not (on_stack(this_frame, fname, lineno)): Scalene.update_profiled() pywhere.set_last_profiled_invalidated_false() @@ -780,11 +769,6 @@ def output_profile(program_args: list[str] | None = None) -> bool: ) return did_output - @staticmethod - def print_stacks() -> None: - for f in Scalene.__stats.stacks: - print(f, Scalene.__stats.stacks[f]) - @staticmethod def _set_in_jupyter() -> None: """Tell Scalene that it is running inside a Jupyter notebook.""" @@ -1182,7 +1166,6 @@ def start() -> None: Scalene.__stats.start_clock() Scalene.enable_signals() Scalene.__start_time = time.monotonic_ns() - Scalene.__done = False # Start neuron monitor if using Neuron accelerator if ( @@ -1199,7 +1182,6 @@ def start() -> None: @staticmethod def stop() -> None: """Complete profiling.""" - Scalene.__done = True if Scalene.__args.memory: from scalene import pywhere # type: ignore @@ -1238,11 +1220,6 @@ def stop() -> None: Scalene.__output.html = False Scalene.__output.output_file = Scalene.__profile_filename - @staticmethod - def is_done() -> bool: - """Return true if Scalene has stopped profiling.""" - return Scalene.__done - @staticmethod def _start_signal_handler( _signum: SignumType, diff --git a/tests/test_coverup_103.py b/tests/test_coverup_103.py deleted file mode 100644 index 42e7f8743..000000000 --- a/tests/test_coverup_103.py +++ /dev/null @@ -1,38 +0,0 @@ -# file scalene/scalene_profiler.py:895-897 -# lines [895, 896, 897] -# branches [] - -import pytest -from scalene.scalene_profiler import Scalene -from scalene.scalene_statistics import StackFrame, StackStats - - -# Create a fixture to setup the Scalene for testing -@pytest.fixture -def scalene_profiler(): - # Setup code if necessary - yield Scalene - # Teardown code if necessary - - -def test_print_stacks(capsys, scalene_profiler): - # Create test stacks - stack1 = StackFrame("test_file1.py", "test_function1", 1) - stack2 = StackFrame("test_file2.py", "test_function2", 2) - stats1 = StackStats(1, 1.0, 0.5, 2) - stats2 = StackStats(2, 2.0, 1.0, 4) - - # Set up test data - scalene_profiler._Scalene__stats.stacks = {(stack1,): stats1, (stack2,): stats2} - - # Call the function - scalene_profiler.print_stacks() - - # Capture the output - captured = capsys.readouterr() - - # Verify the output contains the expected stack information - assert "test_file1.py" in captured.out - assert "test_function1" in captured.out - assert "test_file2.py" in captured.out - assert "test_function2" in captured.out diff --git a/tests/test_coverup_95.py b/tests/test_coverup_95.py deleted file mode 100644 index 6cb1b2633..000000000 --- a/tests/test_coverup_95.py +++ /dev/null @@ -1,23 +0,0 @@ -# file scalene/scalene_profiler.py:1624-1627 -# lines [1624, 1625, 1627] -# branches [] - -import pytest -from scalene.scalene_profiler import Scalene - - -@pytest.fixture(scope="function") -def scalene_cleanup(): - # Setup: None needed for this test - yield - # Teardown: Reset the __done flag to False after the test - Scalene._Scalene__done = False - - -def test_is_done(scalene_cleanup): - # Initially, __done should be False - assert not Scalene.is_done() - # Set the __done flag to True to simulate the end of profiling - Scalene._Scalene__done = True - # Now, is_done should return True - assert Scalene.is_done()