scope-profiler 0.7.1__tar.gz → 0.7.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/CMakeLists.txt +1 -1
- {scope_profiler-0.7.1/src/scope_profiler.egg-info → scope_profiler-0.7.2}/PKG-INFO +1 -1
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/pyproject.toml +1 -1
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/summary.py +147 -64
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_app.py +5 -3
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_inspection.py +12 -10
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_results_api.py +105 -8
- scope_profiler-0.7.2/src/scope_profiler/tests/unit/test_summary_rendering.py +88 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2/src/scope_profiler.egg-info}/PKG-INFO +1 -1
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler.egg-info/SOURCES.txt +2 -1
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/LICENSE.txt +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/MANIFEST.in +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/README.md +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/cmake/scope-profilerConfig.cmake.in +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/cmake/CMakeLists.txt +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/cmake/main.cpp +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/cmake/mpi.cpp +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/cmake/native.c +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/ex_mpi_numpy_wrappers.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/ex_mpi_profiling_options.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/examples/ex_mpi_wrappers.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/setup.cfg +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/__main__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/_assets/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/_assets/scope-profiler-plotly-0.2.0.js +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/benchmark.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/Makefile +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/example.c +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler.c +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler.h +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler.hpp +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler_hdf5.h +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler_impl.h +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/c/scope_profiler_mpi.hpp +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/call_stack.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/chrome_trace_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/concurrency.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/diff.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/fortran/Makefile +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/fortran/example.f90 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/fortran/scope_profiler.f90 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/gpu_timing.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/h5reader.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/h5schema.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/h5writer.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/html_report.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/inspection.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/ipython_magics.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/json_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/likwid_data.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/line_profile_cli.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mcp_server/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mcp_server/__main__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mcp_server/server.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mcp_server/tools.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/memray.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/metadata.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mpi_launch.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mpi_region.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/mpi_wrappers.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/native_trace.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/perf_events.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/_utils.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/callgraph.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/duration_timeseries.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/durations.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/flame.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/gantt.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/heatmap.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/histogram.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/imbalance.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/likwid.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/perf_events.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/roofline.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/scaling.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/statistics.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/plotting_scripts/timeline.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/post_processing.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/prof_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/profile_config.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/profile_io.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/profile_manager.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/py.typed +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/pytest_plugin.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/region.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/region_profiler.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/results.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/speedscope_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/check_mpi_launch.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/check_parallel_hdf5.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/conftest.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/examples.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/examples_pylikwid.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/README.md +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/hdf5-schema-1.h5.gz.b64 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/hdf5-schema-2.h5.gz.b64 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/hdf5-schema-3.h5.gz.b64 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/json-v1.json +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/native-v1.spt.b64 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/fixtures/compatibility/native-v2.spt.b64 +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/pylikwid_readme.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_aggregation.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_api_shortcuts.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_async_profiling.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_benchmark.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_buffer_growth.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_c_api.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_c_hdf5_output.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_chrome_trace_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_compatibility_fixtures.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_diff.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_documented_formats.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_fortran_api.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_html_report.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_in_memory_results.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_ipython_magics.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_json_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_label.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_likwid_data.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_line_profile_cli.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_main_cli.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_mcp_server.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_mcp_tools.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_memray.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_metadata.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_mixed_language.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_mpi.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_multiple_sessions.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_multiprocessing.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_output_size.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_overhead.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_overhead_io.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_perf_events.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_post_processing.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_prof_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_profile_config_toml.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_profiling_options.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_pytest_plugin.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_readme.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_region_source.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_repeated_finalize.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_set_version.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_speedscope_export.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_storage_size.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_summary_likwid.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_threading.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/test_tui.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/__init__.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_call_stack.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_call_stack_properties.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_callgraph_plot.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_concurrency.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_gpu_timing.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_h5_failure_paths.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_h5_roundtrip.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_h5writer.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_lazy_config.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_likwid_child_env.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_merge_results.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_mpi_launch.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_mpi_wrappers.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_native_hdf5_inputs.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_native_trace_versions.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_payload_collection.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_recursive_tracer.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tests/unit/test_region_variants.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler/tui.py +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler.egg-info/dependency_links.txt +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler.egg-info/entry_points.txt +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler.egg-info/requires.txt +0 -0
- {scope_profiler-0.7.1 → scope_profiler-0.7.2}/src/scope_profiler.egg-info/top_level.txt +0 -0
|
@@ -14,16 +14,28 @@ import shlex
|
|
|
14
14
|
import sys
|
|
15
15
|
|
|
16
16
|
import numpy as np
|
|
17
|
-
from tabulate import tabulate
|
|
17
|
+
from tabulate import DataRow, Line, TableFormat, tabulate
|
|
18
|
+
|
|
19
|
+
_REGION_TABLE_FORMAT = TableFormat(
|
|
20
|
+
lineabove=Line("╭", "─", "──", "╮"),
|
|
21
|
+
linebelowheader=Line("├", "─", "──", "┤"),
|
|
22
|
+
linebetweenrows=None,
|
|
23
|
+
linebelow=Line("╰", "─", "──", "╯"),
|
|
24
|
+
headerrow=DataRow("│", " ", "│"),
|
|
25
|
+
datarow=DataRow("│", " ", "│"),
|
|
26
|
+
padding=1,
|
|
27
|
+
with_header_hide=None,
|
|
28
|
+
)
|
|
18
29
|
|
|
19
30
|
|
|
20
|
-
def _print_table(rows, headers, stream, title=None) -> None:
|
|
21
|
-
"""Print
|
|
31
|
+
def _print_table(rows, headers, stream, title=None, tablefmt="rounded_outline") -> None:
|
|
32
|
+
"""Print an aligned, header-separated table."""
|
|
22
33
|
lines = tabulate(
|
|
23
34
|
rows,
|
|
24
35
|
headers=headers,
|
|
25
|
-
tablefmt=
|
|
36
|
+
tablefmt=tablefmt,
|
|
26
37
|
disable_numparse=True,
|
|
38
|
+
preserve_whitespace=True,
|
|
27
39
|
).splitlines()
|
|
28
40
|
if title:
|
|
29
41
|
width = max(len(line) for line in lines)
|
|
@@ -67,7 +79,7 @@ _COLUMNS = (
|
|
|
67
79
|
("total", "total [s]"),
|
|
68
80
|
("percent", "% session"),
|
|
69
81
|
("parent_percent", "% parent"),
|
|
70
|
-
("avg", "avg [s]"),
|
|
82
|
+
("avg", "avg/call [s]"),
|
|
71
83
|
("min", "min [s]"),
|
|
72
84
|
("max", "max [s]"),
|
|
73
85
|
("first", "first [s]"),
|
|
@@ -83,11 +95,8 @@ REGION_TABLE_COLUMN_NAMES = tuple(key for key, _ in _COLUMNS)
|
|
|
83
95
|
REGION_TABLE_COLUMNS = ("region", *REGION_TABLE_COLUMN_NAMES[1:])
|
|
84
96
|
DEFAULT_REGION_TABLE_COLUMNS = (
|
|
85
97
|
"region",
|
|
86
|
-
"calls",
|
|
87
98
|
"percent",
|
|
88
|
-
"parent_percent",
|
|
89
99
|
"total",
|
|
90
|
-
"avg",
|
|
91
100
|
)
|
|
92
101
|
_COLUMN_ALIASES = {"region": "name", "name": "name"}
|
|
93
102
|
_COLUMN_ALIASES.update({key: key for key, _ in _COLUMNS if key != "name"})
|
|
@@ -375,6 +384,20 @@ def region_rows(
|
|
|
375
384
|
for rank in selected_ranks:
|
|
376
385
|
try:
|
|
377
386
|
calls = results.call_stack(rank=rank, include=include, exclude=exclude)
|
|
387
|
+
if include is not None or exclude is not None:
|
|
388
|
+
# Hidden children still consume time: filtering the display
|
|
389
|
+
# must not turn their duration into their parent's own time.
|
|
390
|
+
full_calls = results.call_stack(rank=rank)
|
|
391
|
+
exclusive_by_call = {
|
|
392
|
+
(call["name"], call["start"], call["end"]): call[
|
|
393
|
+
"exclusive_duration"
|
|
394
|
+
]
|
|
395
|
+
for call in full_calls
|
|
396
|
+
}
|
|
397
|
+
for call in calls:
|
|
398
|
+
call["exclusive_duration"] = exclusive_by_call[
|
|
399
|
+
(call["name"], call["start"], call["end"])
|
|
400
|
+
]
|
|
378
401
|
except (NestingError, EventDataUnavailableError):
|
|
379
402
|
# Keep summary output available for legacy profiles containing
|
|
380
403
|
# overlapping intervals that cannot form a call tree. Do not
|
|
@@ -493,7 +516,50 @@ def region_rows(
|
|
|
493
516
|
rows = display_rows
|
|
494
517
|
|
|
495
518
|
if sort == "start":
|
|
496
|
-
|
|
519
|
+
# A summary row pools every invocation of a call path. Sorting that
|
|
520
|
+
# flat set by its earliest invocation can put a later descendant
|
|
521
|
+
# after an unrelated sibling whose own earliest invocation happened
|
|
522
|
+
# in an earlier (possibly empty) episode. The table renderer uses
|
|
523
|
+
# indentation, so rows must instead be emitted as complete subtrees.
|
|
524
|
+
# Sort roots and siblings chronologically, then traverse pre-order.
|
|
525
|
+
# This preserves the useful chronological ordering without making a
|
|
526
|
+
# child appear beneath the wrong preceding row.
|
|
527
|
+
paths = {
|
|
528
|
+
tuple(row["call_path"].split(" > ")): row
|
|
529
|
+
for row in rows
|
|
530
|
+
if "call_path" in row
|
|
531
|
+
}
|
|
532
|
+
children = {path: [] for path in paths}
|
|
533
|
+
roots = []
|
|
534
|
+
for path, row in paths.items():
|
|
535
|
+
parent = path[:-1]
|
|
536
|
+
if parent in paths:
|
|
537
|
+
children[parent].append((path, row))
|
|
538
|
+
else:
|
|
539
|
+
roots.append((path, row))
|
|
540
|
+
|
|
541
|
+
def subtree_rows(path, row):
|
|
542
|
+
subtree = [row]
|
|
543
|
+
for child_path, child in sorted(
|
|
544
|
+
children[path], key=lambda item: item[1]["start"]
|
|
545
|
+
):
|
|
546
|
+
subtree.extend(subtree_rows(child_path, child))
|
|
547
|
+
return subtree
|
|
548
|
+
|
|
549
|
+
# Rows without a reconstructable call path remain chronological too.
|
|
550
|
+
# They cannot be part of the indented tree, so treat each as a root
|
|
551
|
+
# block when merging the chronologically ordered tree blocks.
|
|
552
|
+
no_path_rows = [row for row in rows if "call_path" not in row]
|
|
553
|
+
blocks = [
|
|
554
|
+
(row["start"], index, subtree_rows(path, row))
|
|
555
|
+
for index, (path, row) in enumerate(roots)
|
|
556
|
+
]
|
|
557
|
+
root_count = len(blocks)
|
|
558
|
+
blocks.extend(
|
|
559
|
+
(row["start"], root_count + index, [row])
|
|
560
|
+
for index, row in enumerate(no_path_rows)
|
|
561
|
+
)
|
|
562
|
+
rows = [row for _, _, block in sorted(blocks) for row in block]
|
|
497
563
|
else:
|
|
498
564
|
# Sort by name first so that the stable sort below breaks ties
|
|
499
565
|
# alphabetically rather than by whatever order the file happened to use.
|
|
@@ -507,9 +573,9 @@ def region_rows(
|
|
|
507
573
|
return rows
|
|
508
574
|
|
|
509
575
|
|
|
510
|
-
def _format_duration(value) -> str:
|
|
576
|
+
def _format_duration(value, decimals=3) -> str:
|
|
511
577
|
"""Format a duration in seconds, or a dash when no timing was recorded."""
|
|
512
|
-
return "-" if value is None else f"{value:.
|
|
578
|
+
return "-" if value is None else f"{value:.{decimals}f}"
|
|
513
579
|
|
|
514
580
|
|
|
515
581
|
def _format_count(value) -> str:
|
|
@@ -523,29 +589,31 @@ def _format_count(value) -> str:
|
|
|
523
589
|
return str(value)
|
|
524
590
|
|
|
525
591
|
|
|
526
|
-
def _format_percentage(value, denominator) -> str:
|
|
527
|
-
"""Format a duration as a
|
|
528
|
-
|
|
529
|
-
Fixed-point notation is easier to scan in terminal tables. Scientific
|
|
530
|
-
notation is retained only below 0.01%, where two decimal places would
|
|
531
|
-
otherwise turn a non-zero value into ``0.00%``.
|
|
532
|
-
"""
|
|
592
|
+
def _format_percentage(value, denominator, decimals=2) -> str:
|
|
593
|
+
"""Format a duration as a percentage with the requested precision."""
|
|
533
594
|
if value is None or denominator is None or denominator <= 0:
|
|
534
595
|
return "-"
|
|
535
596
|
percentage = 100.0 * value / denominator
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
597
|
+
return f"{percentage:.{decimals}f}%"
|
|
598
|
+
|
|
599
|
+
|
|
600
|
+
def _tree_prefix(row) -> str:
|
|
601
|
+
depth = row.get("depth", 0)
|
|
602
|
+
return f"{'│ ' * (depth - 1)}└─ " if depth else ""
|
|
539
603
|
|
|
540
604
|
|
|
541
605
|
def _display_region_name(row) -> str:
|
|
542
606
|
"""Render a hierarchical name, marking a collapsed recursive chain."""
|
|
543
|
-
|
|
544
|
-
prefix = f"{'│ ' * (depth - 1)}└─ " if depth else ""
|
|
607
|
+
prefix = _tree_prefix(row)
|
|
545
608
|
recursive = " ↻" if row.get("recursive") else ""
|
|
546
609
|
return f"{prefix}{row['name']}{recursive}"
|
|
547
610
|
|
|
548
611
|
|
|
612
|
+
def _column_indent(row) -> str:
|
|
613
|
+
"""Match the region's tree indentation using only spaces."""
|
|
614
|
+
return " " * len(_tree_prefix(row))
|
|
615
|
+
|
|
616
|
+
|
|
549
617
|
def print_region_table(
|
|
550
618
|
rows,
|
|
551
619
|
title=None,
|
|
@@ -569,15 +637,14 @@ def print_region_table(
|
|
|
569
637
|
suppress_notes : bool, optional
|
|
570
638
|
Don't print the explanatory notes below the table (default: False).
|
|
571
639
|
total_time : float, optional
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
below the TOTAL row when given. Unlike that row -- which sums region
|
|
575
|
-
durations and so can exceed the run's real duration when regions
|
|
576
|
-
nest -- this is the run's own actual wall-clock time.
|
|
640
|
+
Accepted for compatibility. Session elapsed time is shown in the
|
|
641
|
+
``scope_profiler.session`` row.
|
|
577
642
|
columns : list of str or str, optional
|
|
578
|
-
Region summary columns to print. Defaults to ``region``,
|
|
579
|
-
``percent`` and ``
|
|
580
|
-
|
|
643
|
+
Region summary columns to print. Defaults to ``region``,
|
|
644
|
+
``percent`` and ``total``. An indented ``(own)`` row shows
|
|
645
|
+
time excluding children for each parent region. Call counts other than one
|
|
646
|
+
appear after region names unless a separate ``calls`` column is
|
|
647
|
+
explicitly selected. The percentage is
|
|
581
648
|
relative to ``scope_profiler.session``. The public name for the first
|
|
582
649
|
column is ``region``; ``name`` is accepted as an alias for Python
|
|
583
650
|
callers.
|
|
@@ -604,18 +671,25 @@ def print_region_table(
|
|
|
604
671
|
# Percentages are defined relative to the session root. When a
|
|
605
672
|
# filtered table does not contain that root, omit the unusable column
|
|
606
673
|
# from the default layout rather than filling it with dashes.
|
|
607
|
-
columns = ("region", "
|
|
674
|
+
columns = ("region", "total")
|
|
608
675
|
selected_columns = normalize_region_table_columns(columns)
|
|
676
|
+
inline_counts = not any(key == "calls" for key, _ in selected_columns)
|
|
609
677
|
|
|
610
678
|
formatted = [
|
|
611
679
|
{
|
|
612
|
-
"name": _display_region_name(row)
|
|
680
|
+
"name": _display_region_name(row)
|
|
681
|
+
+ (
|
|
682
|
+
f" ({_format_count(row['calls'])}x)"
|
|
683
|
+
if inline_counts and row["calls"] != 1
|
|
684
|
+
else ""
|
|
685
|
+
),
|
|
613
686
|
"ranks": str(row["num_ranks"]),
|
|
614
687
|
"calls": _format_count(row["calls"]),
|
|
615
|
-
"total": _format_duration(row["total"]),
|
|
688
|
+
"total": _column_indent(row) + _format_duration(row["total"], decimals=6),
|
|
616
689
|
# The session root represents the complete run, so keep it at
|
|
617
690
|
# 100% even when exclusive attribution is selected.
|
|
618
|
-
"percent":
|
|
691
|
+
"percent": _column_indent(row)
|
|
692
|
+
+ _format_percentage(
|
|
619
693
|
(
|
|
620
694
|
row["total"]
|
|
621
695
|
if percentage_mode == "exclusive"
|
|
@@ -623,12 +697,16 @@ def print_region_table(
|
|
|
623
697
|
else row.get(percentage_mode)
|
|
624
698
|
),
|
|
625
699
|
session_total,
|
|
700
|
+
decimals=2,
|
|
626
701
|
),
|
|
627
|
-
|
|
702
|
+
# Match the hierarchy without repeating the region's tree lines.
|
|
703
|
+
"parent_percent": _column_indent(row)
|
|
704
|
+
+ _format_percentage(
|
|
628
705
|
row.get("coverage"),
|
|
629
706
|
row.get("parent_coverage"),
|
|
630
707
|
),
|
|
631
|
-
"avg":
|
|
708
|
+
"avg": _column_indent(row)
|
|
709
|
+
+ ("-" if row["avg"] is None else f"{row['avg']:.3e}"),
|
|
632
710
|
"min": _format_duration(row["min"]),
|
|
633
711
|
"max": _format_duration(row["max"]),
|
|
634
712
|
"first": _format_duration(row["first"]),
|
|
@@ -637,40 +715,45 @@ def print_region_table(
|
|
|
637
715
|
"p50": _format_duration(row["p50"]),
|
|
638
716
|
"p95": _format_duration(row["p95"]),
|
|
639
717
|
"p99": _format_duration(row["p99"]),
|
|
640
|
-
"imbalance":
|
|
718
|
+
"imbalance": "-" if row["imbalance"] is None else f"{row['imbalance']:.2f}",
|
|
641
719
|
}
|
|
642
720
|
for row in rows
|
|
643
721
|
]
|
|
644
722
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
723
|
+
parent_paths = {
|
|
724
|
+
" > ".join(parts[:index])
|
|
725
|
+
for row in rows
|
|
726
|
+
if (parts := row.get("call_path", "").split(" > "))
|
|
727
|
+
for index in range(1, len(parts))
|
|
728
|
+
}
|
|
729
|
+
with_own_rows = []
|
|
730
|
+
for row, display in zip(rows, formatted):
|
|
731
|
+
with_own_rows.append(display)
|
|
732
|
+
if row.get("call_path") not in parent_paths:
|
|
733
|
+
continue
|
|
734
|
+
own = {"name": "(own)", "depth": row.get("depth", 0) + 1}
|
|
735
|
+
indent = _column_indent(own)
|
|
736
|
+
own_display = {key: "" for key in display}
|
|
737
|
+
own_display.update(
|
|
738
|
+
name=_display_region_name(own),
|
|
739
|
+
total=indent + _format_duration(row.get("exclusive"), decimals=6),
|
|
740
|
+
avg=indent
|
|
741
|
+
+ (
|
|
742
|
+
f"{row['exclusive'] / row['calls']:.3e}"
|
|
743
|
+
if row.get("exclusive") is not None and row["calls"]
|
|
744
|
+
else "-"
|
|
745
|
+
),
|
|
746
|
+
percent=indent
|
|
747
|
+
+ _format_percentage(row.get("exclusive"), session_total, decimals=2),
|
|
748
|
+
parent_percent=indent
|
|
749
|
+
+ _format_percentage(row.get("exclusive"), row.get("coverage")),
|
|
750
|
+
)
|
|
751
|
+
with_own_rows.append(own_display)
|
|
752
|
+
formatted = with_own_rows
|
|
670
753
|
|
|
671
754
|
headers = [header for _, header in selected_columns]
|
|
672
755
|
table_rows = [[row[key] for key, _ in selected_columns] for row in formatted]
|
|
673
|
-
_print_table(table_rows, headers, stream)
|
|
756
|
+
_print_table(table_rows, headers, stream, tablefmt=_REGION_TABLE_FORMAT)
|
|
674
757
|
notes = []
|
|
675
758
|
if title:
|
|
676
759
|
notes.append(f"Summary: {title}")
|
|
@@ -502,16 +502,18 @@ def test_finalize_prints_the_shared_summary_table(tmp_path, capsys):
|
|
|
502
502
|
ProfileManager.finalize()
|
|
503
503
|
printed = capsys.readouterr().out
|
|
504
504
|
|
|
505
|
-
# Same header, columns and
|
|
505
|
+
# Same header, columns and own-time rows as ProfilingResults.print_summary().
|
|
506
506
|
results = read_h5(file_path)
|
|
507
507
|
results.print_summary()
|
|
508
508
|
assert printed == capsys.readouterr().out
|
|
509
509
|
|
|
510
510
|
header = next(line for line in printed.splitlines() if "region" in line)
|
|
511
|
-
assert "region" in header and "
|
|
511
|
+
assert "region" in header and "total [s]" in header
|
|
512
|
+
assert "avg/call [s]" not in header
|
|
512
513
|
assert "min [s]" not in header and "std [s]" not in header
|
|
513
514
|
assert "outer" in printed and "inner" in printed
|
|
514
|
-
assert "TOTAL" in printed
|
|
515
|
+
assert "TOTAL" not in printed
|
|
516
|
+
assert "(own)" in printed
|
|
515
517
|
# The old per-region block format is gone.
|
|
516
518
|
assert "Total Calls" not in printed
|
|
517
519
|
|
|
@@ -115,7 +115,7 @@ def test_inspect_prints_metadata_and_regions(sample_file, capsys):
|
|
|
115
115
|
# Region table with overall stats
|
|
116
116
|
assert "Regions (2)" in out
|
|
117
117
|
header = next(line for line in out.splitlines() if "total [s]" in line)
|
|
118
|
-
assert "total [s]" in header and "avg [s]" in header
|
|
118
|
+
assert "total [s]" in header and "avg/call [s]" not in header
|
|
119
119
|
assert "min [s]" not in header and "std [s]" not in header
|
|
120
120
|
assert "setup" in out and "solve" in out
|
|
121
121
|
assert "TOTAL" not in out
|
|
@@ -155,13 +155,13 @@ def test_region_statistics_are_seconds(sample_file, capsys):
|
|
|
155
155
|
line = next(
|
|
156
156
|
line for line in capsys.readouterr().out.splitlines() if "solve" in line
|
|
157
157
|
)
|
|
158
|
-
fields =
|
|
158
|
+
fields = line.strip("│ ").split()
|
|
159
159
|
|
|
160
160
|
assert fields[0] == "solve"
|
|
161
161
|
assert fields[1] == "2" # ranks
|
|
162
162
|
assert fields[2] == "4" # calls
|
|
163
163
|
assert float(fields[3]) == pytest.approx(13.0) # total
|
|
164
|
-
assert float(fields[4]) == pytest.approx(3.
|
|
164
|
+
assert float(fields[4]) == pytest.approx(3.25) # avg, displayed to 3 decimals
|
|
165
165
|
assert float(fields[5]) == pytest.approx(2.0) # min
|
|
166
166
|
assert float(fields[6]) == pytest.approx(4.0) # max
|
|
167
167
|
|
|
@@ -182,17 +182,19 @@ def test_long_metadata_values_are_clipped_unless_full(sample_file, capsys):
|
|
|
182
182
|
def test_sorting(sample_file, capsys):
|
|
183
183
|
inspect_file(sample_file, sort="total")
|
|
184
184
|
ordered = [
|
|
185
|
-
line.strip("│ ").split(
|
|
185
|
+
line.strip("│ ").split()[0]
|
|
186
186
|
for line in capsys.readouterr().out.splitlines()
|
|
187
|
-
if
|
|
187
|
+
if line.strip("│ ").split()
|
|
188
|
+
and line.strip("│ ").split()[0] in {"setup", "solve"}
|
|
188
189
|
]
|
|
189
190
|
assert ordered == ["solve", "setup"] # solve: 13 s, setup: 4 s
|
|
190
191
|
|
|
191
192
|
inspect_file(sample_file, sort="name")
|
|
192
193
|
ordered = [
|
|
193
|
-
line.strip("│ ").split(
|
|
194
|
+
line.strip("│ ").split()[0]
|
|
194
195
|
for line in capsys.readouterr().out.splitlines()
|
|
195
|
-
if
|
|
196
|
+
if line.strip("│ ").split()
|
|
197
|
+
and line.strip("│ ").split()[0] in {"setup", "solve"}
|
|
196
198
|
]
|
|
197
199
|
assert ordered == ["setup", "solve"]
|
|
198
200
|
|
|
@@ -211,8 +213,8 @@ def test_include_exclude_and_ranks(sample_file, capsys):
|
|
|
211
213
|
line = next(
|
|
212
214
|
line for line in capsys.readouterr().out.splitlines() if "solve" in line
|
|
213
215
|
)
|
|
214
|
-
fields =
|
|
215
|
-
assert fields[1] == "
|
|
216
|
+
fields = line.strip("│ ").split()
|
|
217
|
+
assert fields[1] == "(2x)" # calls appear after the region name
|
|
216
218
|
|
|
217
219
|
|
|
218
220
|
def test_section_switches(sample_file, capsys):
|
|
@@ -318,7 +320,7 @@ def test_cli_accepts_region_table_columns(sample_file, capsys):
|
|
|
318
320
|
out = capsys.readouterr().out
|
|
319
321
|
header = next(line for line in out.splitlines() if "total [s]" in line)
|
|
320
322
|
|
|
321
|
-
assert "total [s]" in header and "avg [s]" in header
|
|
323
|
+
assert "total [s]" in header and "avg/call [s]" in header
|
|
322
324
|
assert "min [s]" not in header
|
|
323
325
|
assert "imbalance [%]" not in header
|
|
324
326
|
assert "setup" in out and "solve" in out and "TOTAL" not in out
|
|
@@ -141,16 +141,98 @@ def test_summary_pools_same_named_regions_by_call_path(capsys):
|
|
|
141
141
|
line for line in capsys.readouterr().out.splitlines() if "work" in line
|
|
142
142
|
]
|
|
143
143
|
assert len(work_lines) == 2
|
|
144
|
-
assert "
|
|
145
|
-
assert "
|
|
144
|
+
assert "0.000" in work_lines[0]
|
|
145
|
+
assert "0.000" in work_lines[1]
|
|
146
146
|
|
|
147
147
|
|
|
148
|
-
def
|
|
148
|
+
def test_summary_start_order_keeps_aggregated_call_path_subtrees_together():
|
|
149
|
+
"""An early empty episode must not detach a later path descendant."""
|
|
150
|
+
results = ProfilingResults(
|
|
151
|
+
{
|
|
152
|
+
"run": MPIRegion(
|
|
153
|
+
"run", {0: Region(np.array([0, 20]), np.array([10, 100]))}
|
|
154
|
+
),
|
|
155
|
+
"loop": MPIRegion(
|
|
156
|
+
"loop", {0: Region(np.array([3, 25]), np.array([4, 90]))}
|
|
157
|
+
),
|
|
158
|
+
"final": MPIRegion(
|
|
159
|
+
"final", {0: Region(np.array([5, 91]), np.array([6, 99]))}
|
|
160
|
+
),
|
|
161
|
+
"solve": MPIRegion(
|
|
162
|
+
"solve", {0: Region(np.array([26, 92]), np.array([30, 95]))}
|
|
163
|
+
),
|
|
164
|
+
}
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
from scope_profiler.summary import region_rows
|
|
168
|
+
|
|
169
|
+
assert [row["call_path"] for row in region_rows(results)] == [
|
|
170
|
+
"run",
|
|
171
|
+
"run > loop",
|
|
172
|
+
"run > loop > solve",
|
|
173
|
+
"run > final",
|
|
174
|
+
"run > final > solve",
|
|
175
|
+
]
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def _staged_branch_results(branches):
|
|
179
|
+
"""Build repeated empty/real branch episodes with arbitrary depths."""
|
|
180
|
+
intervals_by_name = {"run": ([0, 1_000], [100, 10_000])}
|
|
181
|
+
for branch_index, branch in enumerate(branches):
|
|
182
|
+
base = 1_100 + branch_index * 1_000
|
|
183
|
+
for depth, name in enumerate(branch):
|
|
184
|
+
starts, ends = intervals_by_name.setdefault(name, ([], []))
|
|
185
|
+
if depth == 0:
|
|
186
|
+
# The first stage has only this empty branch root. Its early
|
|
187
|
+
# start is what previously separated it from real descendants.
|
|
188
|
+
starts.append(10 + branch_index * 10)
|
|
189
|
+
ends.append(11 + branch_index * 10)
|
|
190
|
+
starts.append(base + depth * 10)
|
|
191
|
+
ends.append(base + 900 - depth * 10)
|
|
192
|
+
return ProfilingResults(
|
|
193
|
+
{
|
|
194
|
+
name: MPIRegion(name, {0: Region(np.array(starts), np.array(ends))})
|
|
195
|
+
for name, (starts, ends) in intervals_by_name.items()
|
|
196
|
+
}
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
@pytest.mark.parametrize(
|
|
201
|
+
"branches",
|
|
202
|
+
[
|
|
203
|
+
(("loop", "solve"), ("final", "solve")),
|
|
204
|
+
(("prepare", "assemble", "factor"), ("final", "solve")),
|
|
205
|
+
(("predict", "solve"), ("correct", "solve"), ("final", "solve")),
|
|
206
|
+
(("loop", "solve", "minimize"), ("final", "solve")),
|
|
207
|
+
(("load", "parse"), ("compute", "work", "kernel")),
|
|
208
|
+
(("warmup", "work"), ("production", "work", "reduce")),
|
|
209
|
+
(("first", "shared", "leaf"), ("second", "shared", "leaf")),
|
|
210
|
+
(("outer_a", "middle", "inner", "leaf"), ("outer_b", "work")),
|
|
211
|
+
(("precondition", "iterate", "residual"), ("postprocess", "write")),
|
|
212
|
+
(("phase_a", "task", "step"), ("phase_b", "task"), ("phase_c", "task")),
|
|
213
|
+
],
|
|
214
|
+
)
|
|
215
|
+
def test_summary_start_order_keeps_each_staged_branch_subtree_together(branches):
|
|
216
|
+
"""Ten varied staged profiles guard against detached summary children."""
|
|
217
|
+
from scope_profiler.summary import region_rows
|
|
218
|
+
|
|
219
|
+
expected_paths = ["run"]
|
|
220
|
+
for branch in branches:
|
|
221
|
+
expected_paths.extend(
|
|
222
|
+
"run > " + " > ".join(branch[:depth]) for depth in range(1, len(branch) + 1)
|
|
223
|
+
)
|
|
224
|
+
|
|
225
|
+
assert [
|
|
226
|
+
row["call_path"] for row in region_rows(_staged_branch_results(branches))
|
|
227
|
+
] == (expected_paths)
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
def test_summary_percentages_use_two_decimal_places():
|
|
149
231
|
from scope_profiler.summary import _format_percentage
|
|
150
232
|
|
|
151
233
|
assert _format_percentage(1, 1) == "100.00%"
|
|
152
234
|
assert _format_percentage(0.001, 1) == "0.10%"
|
|
153
|
-
assert _format_percentage(0.00001, 1) == "
|
|
235
|
+
assert _format_percentage(0.00001, 1) == "0.00%"
|
|
154
236
|
|
|
155
237
|
|
|
156
238
|
def test_summary_percentage_uses_coverage_for_nested_regions(capsys):
|
|
@@ -177,8 +259,14 @@ def test_summary_percentage_uses_coverage_for_nested_regions(capsys):
|
|
|
177
259
|
assert "100.00%" in output
|
|
178
260
|
assert "80.00%" in output
|
|
179
261
|
assert "60.00%" in output
|
|
180
|
-
assert "% parent" in output
|
|
181
|
-
assert "
|
|
262
|
+
assert "% parent" not in output
|
|
263
|
+
assert "own [s]" not in output
|
|
264
|
+
assert output.count("(own)") == 2
|
|
265
|
+
assert "(1x)" not in output
|
|
266
|
+
header = next(line for line in output.splitlines() if "% session" in line)
|
|
267
|
+
assert (
|
|
268
|
+
header.index("region") < header.index("% session") < header.index("total [s]")
|
|
269
|
+
)
|
|
182
270
|
assert "100.00%" in output
|
|
183
271
|
|
|
184
272
|
results.print_summary(percentage_mode="exclusive")
|
|
@@ -187,6 +275,14 @@ def test_summary_percentage_uses_coverage_for_nested_regions(capsys):
|
|
|
187
275
|
assert "20.00%" in exclusive_output
|
|
188
276
|
assert "60.00%" in exclusive_output
|
|
189
277
|
|
|
278
|
+
from scope_profiler.summary import region_rows
|
|
279
|
+
|
|
280
|
+
rows = {row["name"]: row for row in region_rows(results)}
|
|
281
|
+
assert rows["outer"]["exclusive"] == pytest.approx(20 / NS)
|
|
282
|
+
assert rows["inner"]["exclusive"] == pytest.approx(60 / NS)
|
|
283
|
+
filtered = region_rows(results, include="outer")
|
|
284
|
+
assert filtered[0]["exclusive"] == pytest.approx(20 / NS)
|
|
285
|
+
|
|
190
286
|
|
|
191
287
|
def test_region_without_any_calls_is_safe():
|
|
192
288
|
"""A region that recorded nothing still answers every query."""
|
|
@@ -287,7 +383,8 @@ def test_reader_print_summary(sample_file, capsys):
|
|
|
287
383
|
|
|
288
384
|
out = capsys.readouterr().out
|
|
289
385
|
header = next(line for line in out.splitlines() if "region" in line)
|
|
290
|
-
assert "region" in header and "total [s]" in header
|
|
386
|
+
assert "region" in header and "total [s]" in header
|
|
387
|
+
assert "avg/call [s]" not in header
|
|
291
388
|
assert "% session" not in header
|
|
292
389
|
assert "min [s]" not in header and "std [s]" not in header
|
|
293
390
|
assert "setup" in out and "solve" in out
|
|
@@ -308,7 +405,7 @@ def test_reader_print_summary_accepts_columns(sample_file, capsys):
|
|
|
308
405
|
assert "ranks" in header
|
|
309
406
|
assert "n" in header
|
|
310
407
|
assert "total [s]" in header
|
|
311
|
-
assert "avg [s]" in header
|
|
408
|
+
assert "avg/call [s]" in header
|
|
312
409
|
assert "min [s]" not in header
|
|
313
410
|
assert "imbalance [%]" not in header
|
|
314
411
|
assert "setup" in out and "solve" in out and "TOTAL" not in out
|