def test_failed_rebuild(benchmark):
    """The defined model has 8 fields with some relatively complex annotations.

    The last field has an undefined forward annotation, that will fail to resolve on model rebuild.
    The benchmark is used to measure time spent in trying to rebuild a model knowing that it will
    fail when encountering the last field.
    """
    fields: dict[str, Any] = {
        f'f{i}': Annotated[Union[int, Annotated[str, Field(max_length=3)]], AfterValidator(lambda v: v)]
        for i in range(8)
    }
    fields['f8'] = 'Undefined'

    ModelWithUndefinedAnnotation = create_model(  # pyright: ignore[reportCallIssue]
        'ModelWithUndefinedAnnotation',
        __base__=DeferredModel,
        **fields,
    )

    benchmark(rebuild_model, ModelWithUndefinedAnnotation, raise_errors=False)
The defined model has 8 fields with some relatively complex annotations.

    The last field has an undefined forward annotation, that will fail to resolve on model rebuild.
    The benchmark is used to measure time spent in trying to rebuild a model knowing that it will
    fail when encountering the last field.
    
tests/benchmarks/test_model_schema_generation.py