@@ -599,6 +599,16 @@ def pytest_addoption(parser: pytest.Parser) -> None:
599599 "groups, phase 2 generates all supported fixture formats."
600600 ),
601601 )
602+ test_group .addoption (
603+ "--skip-summary" ,
604+ action = "store_true" ,
605+ dest = "skip_summary" ,
606+ default = False ,
607+ help = (
608+ "Skip computing expensive summary statistics "
609+ "(e.g., total account counts)."
610+ ),
611+ )
602612
603613 optimize_gas_group = parser .getgroup (
604614 "optimize gas" ,
@@ -694,6 +704,9 @@ def pytest_configure(config: pytest.Config) -> None:
694704 config
695705 )
696706
707+ # Capture start time for duration reporting
708+ config .session_start_time = datetime .datetime .now () # type: ignore[attr-defined]
709+
697710 if is_help_or_collectonly_mode (config ):
698711 return
699712
@@ -835,33 +848,63 @@ def pytest_terminal_summary(
835848 return
836849 stats = terminalreporter .stats
837850 if "passed" in stats and stats ["passed" ]:
851+ # Calculate duration
852+ duration = datetime .datetime .now () - config .session_start_time # type: ignore[attr-defined]
853+ total_seconds = int (duration .total_seconds ())
854+ hours , remainder = divmod (total_seconds , 3600 )
855+ minutes , seconds = divmod (remainder , 60 )
856+ duration_str = f"{ hours :02d} :{ minutes :02d} :{ seconds :02d} "
857+
838858 # Custom message for Phase 1 (pre-allocation group generation)
839859 session_instance : FillingSession = config .filling_session # type: ignore[attr-defined]
840860 if session_instance .phase_manager .is_pre_alloc_generation :
841- # Generate summary stats
842- pre_alloc_groups : PreAllocGroups
843- if config .pluginmanager .hasplugin ("xdist" ):
844- # Load pre-allocation groups from disk
845- pre_alloc_groups = PreAllocGroups .from_folder (
846- config .fixture_output .pre_alloc_groups_folder_path , # type: ignore[attr-defined]
847- lazy_load = False ,
861+ skip_summary = config .getoption ("skip_summary" )
862+
863+ if skip_summary :
864+ # Fast path: only count groups without loading file contents
865+ pre_alloc_groups : PreAllocGroups
866+ if config .pluginmanager .hasplugin ("xdist" ):
867+ pre_alloc_groups = PreAllocGroups .from_folder (
868+ config .fixture_output .pre_alloc_groups_folder_path , # type: ignore[attr-defined]
869+ lazy_load = True ,
870+ )
871+ else :
872+ assert session_instance .pre_alloc_groups is not None
873+ pre_alloc_groups = session_instance .pre_alloc_groups
874+ total_groups = len (pre_alloc_groups .root )
875+ terminalreporter .write_sep (
876+ "=" ,
877+ f" Phase 1 Complete ({ duration_str } ): "
878+ f"Generated { total_groups } pre-alloc groups " ,
879+ bold = True ,
880+ green = True ,
848881 )
849882 else :
850- assert session_instance .pre_alloc_groups is not None
851- pre_alloc_groups = session_instance .pre_alloc_groups
883+ # Full summary: load all groups and count accounts
884+ pre_alloc_groups_full : PreAllocGroups
885+ if config .pluginmanager .hasplugin ("xdist" ):
886+ pre_alloc_groups_full = PreAllocGroups .from_folder (
887+ config .fixture_output .pre_alloc_groups_folder_path , # type: ignore[attr-defined]
888+ lazy_load = False ,
889+ )
890+ else :
891+ assert session_instance .pre_alloc_groups is not None
892+ pre_alloc_groups_full = session_instance .pre_alloc_groups
852893
853- total_groups = len (pre_alloc_groups .root )
854- total_accounts = sum (
855- group .pre_account_count for group in pre_alloc_groups .values ()
856- )
894+ total_groups = len (pre_alloc_groups_full .root )
895+ total_accounts = sum (
896+ group .pre_account_count
897+ for group in pre_alloc_groups_full .values ()
898+ )
857899
858- terminalreporter .write_sep (
859- "=" ,
860- f" Phase 1 Complete: Generated { total_groups } pre-alloc "
861- f"groups ({ total_accounts } total accounts) " ,
862- bold = True ,
863- green = True ,
864- )
900+ terminalreporter .write_sep (
901+ "=" ,
902+ f" Phase 1 Complete ({ duration_str } ): "
903+ f"Generated { total_groups } pre-alloc groups "
904+ f"({ total_accounts } total accounts) " ,
905+ bold = True ,
906+ green = True ,
907+ )
865908
866909 else :
867910 # Normal message for fixture generation
0 commit comments