code: def test_careduce_performance(
      careduce_fn, numpy_fn, axis, inputs, input_vals
  ):
      g = careduce_fn(*inputs, axis=axis)
  
      pytensor_numba_fn = function(
          inputs,
          g,
          mode=numba_mode,
      )
  
      # pytensor_c_fn = function(
      #     inputs,
      #     g,
      #     mode=Mode("cvm")
      # )
  
      numpy_res = numpy_fn(*input_vals)
      numba_res = pytensor_numba_fn(*input_vals)
      # c_res = pytensor_c_fn(*input_vals)
  
      assert np.array_equal(numba_res, numpy_res)
  
      # FYI: To test the Numba JITed function directly, use `pytensor_numba_fn.vm.jit_fn`
  
      numpy_timer = timeit.Timer(
          "numpy_fn(*input_vals)", "pass", globals=locals()
      )
      numba_timer = timeit.Timer(
          "pytensor_numba_fn.vm.jit_fn(*input_vals)",
          "pass",
          globals=locals(),
      )
      # c_timer = timeit.Timer("pytensor_c_fn(*input_vals)", "pass", globals=locals())
  
      n_loops, _ = numpy_timer.autorange()
  
      numpy_times = numpy_timer.repeat(5, n_loops)
      numba_times = numba_timer.repeat(5, n_loops)
      # c_times = c_timer.repeat(5, n_loops)
  
      mean_numba_time = np.mean(numba_times)
      mean_numpy_time = np.mean(numpy_times)
      # mean_c_time = np.mean(c_times)
  
      # FIXME: Why are we asserting >=? Numba could be doing worse than numpy!
      assert mean_numba_time / mean_numpy_time >= 0.75
  
file_path: pytensor/tests/link/numba/test_performance.py
imports: import timeit
  import numpy
  import pytest
  import pytensor.tensor
  from pytensor import config
  from pytensor.compile.function import function
  from pytensor.compile.mode import Mode
  from pytensor.graph.rewriting.db import RewriteDatabaseQuery
  from pytensor.link.numba.linker import NumbaLinker
  from pytensor.tensor.math import Max
label_desc: Use image node_id 1 for calling a global function with example usage: test_careduce_performance(careduce_fn, numpy_fn, axis, inputs, input_vals) without return types