import numpy as np
import theano.tensor as T
import theano as th

th.config.openmp_elemwise_minsize = 1000
th.config.openmp = True

x = T.vector("x")
y = T.vector("y")

hit_test = x ** 2 + y ** 2 < 1
hits = hit_test.sum()
misses = x.shape[0]
pi_est = 4 * hits / misses

calculate_pi = th.function([x, y], pi_est)

x_val = np.random.uniform(-1, 1, 30000)
y_val = np.random.uniform(-1, 1, 30000)

import timeit

res = timeit.timeit(
    "calculate_pi(x_val, y_val)",
    "from __main__ import x_val, y_val, calculate_pi",
    number=100000,
)
print(res)

import numpy as np
import theano.tensor as T
import theano as th

th.config.openmp_elemwise_minsize = 1000
th.config.openmp = True

x = T.vector("x")
y = T.vector("y")

hit_test = x ** 2 + y ** 2 < 1
hits = hit_test.sum()
misses = x.shape[0]
pi_est = 4 * hits / misses

calculate_pi = th.function([x, y], pi_est)

x_val = np.random.uniform(-1, 1, 30000)
y_val = np.random.uniform(-1, 1, 30000)

import timeit

res = timeit.timeit(
    "calculate_pi(x_val, y_val)",
    "from __main__ import x_val, y_val, calculate_pi",
    number=100000,
)
print(res)
