--- Final Solver (used for performance test) ---
from typing import Any

import numpy as np
from numba import njit


@njit
def _outer(v1, v2, out):
    n = v1.shape[0]
    m = v2.shape[0]
    for i in range(n):
        vi = v1[i]
        for j in range(m):
            out[i, j] = vi * v2[j]


class Solver:
    def __init__(self):
        self._buffer: np.ndarray | None = None
        # Pre-compile the numba function for common dtypes so runtime compilation does not count.
        for dtype in (np.float32, np.float64, np.int32, np.int64, np.complex64, np.complex128):
            v = np.zeros(2, dtype=dtype)
            _outer(v, v, np.empty((2, 2), dtype=dtype))

    def solve(self, problem, **kwargs) -> Any:
        vec1, vec2 = problem
        n = vec1.shape[0]
        dtype = np.result_type(vec1.dtype, vec2.dtype)

        buf = self._buffer
        if buf is None or buf.shape != (n, n) or buf.dtype != dtype:
            buf = np.empty((n, n), dtype=dtype)
            self._buffer = buf

        _outer(vec1, vec2, buf)
        return buf
--- End Solver ---
Running performance test...
============================= test session starts ==============================
platform linux -- Python 3.12.13, pytest-9.0.2, pluggy-1.6.0
rootdir: /tests
plugins: anyio-4.13.0, jaxtyping-0.3.9
collected 3 items

../tests/test_outputs.py .
--- Performance Summary ---
Validity: True
Total Baseline Time: 6.5223s
Total Solver Time:   5.4575s
Raw Speedup:         1.1951 x
Final Reward (Score): 1.1951
---------------------------
..

==================================== PASSES ====================================
=========================== short test summary info ============================
PASSED ../tests/test_outputs.py::test_solver_exists
PASSED ../tests/test_outputs.py::test_solver_validity
PASSED ../tests/test_outputs.py::test_solver_speedup
======================== 3 passed in 196.41s (0:03:16) =========================
