def test_simple_profiler_dirpath(tmp_path):
    """Ensure the profiler dirpath defaults to `trainer.log_dir` when not present."""
    profiler = SimpleProfiler(filename="profiler")
    assert profiler.dirpath is None

    model = BoringModel()
    trainer = Trainer(default_root_dir=tmp_path, max_epochs=1, profiler=profiler, logger=False)
    trainer.fit(model)

    assert trainer.log_dir == str(tmp_path)
    assert profiler.dirpath == str(trainer.log_dir)
    assert (tmp_path / "fit-profiler.txt").exists()
Ensure the profiler dirpath defaults to `trainer.log_dir` when not present.
tests/tests_pytorch/profilers/test_profiler.py