Example #1
0
def execute(D, N, X, beta, tetha):
    initial = time.time()
    functionE.rbf_network(X, beta, tetha)
    tiempoPy = time.time() - initial

    initial = time.time()
    CyfunctionE.rbf_network(X, beta, tetha)
    tiempoCy = time.time() - initial

    SpeedUp = round(tiempoPy / tiempoCy, 3)

    print("tiempo Python: {}\n".format(tiempoPy))
    print("tiempo Cython: {}\n".format(tiempoCy))
    print("tiempo SpeedUp: {}\n".format(SpeedUp))
import numpy as np
import time

### Inicializar  para Python y Cython
D = 5
N = 1500
X = np.array([np.random.rand(N) for d in range(D)]).T
beta = np.random.rand(N)
theta = 10



### Tiempos
time_span = 400
n_steps = 2000000

inicio = time.time()
result1=rbf_network(X, beta, theta)
tiempoPy = time.time() - inicio
### print(result1)

inicio = time.time()
result=Cy_rbf_network(X, beta, theta)
tiempoCy = time.time() - inicio
### print(np.asarray(result))

speedUp = round(tiempoPy/tiempoCy,3)

print("Tiempo Python: {} \n".format(tiempoPy))
print("Tiempo Cython: {} \n".format(tiempoCy))
print("SpeedUp: {} \n".format(speedUp))
Example #3
0
# Inicialización de variables
Py_D = 5
Py_N = 1500
Py_X = np.array([np.random.rand(Py_N) for d in range(Py_D)]).T
Py_beta = np.random.rand(Py_N)
Py_theta = 10

# Listas de Ejecuciones
pTiempoPy, pTiempoCy, pSpeedUp = [], [], []

# Para el test se repetirá n veces la toma de tiempos
n = 30
for i in range(n):
    inicio = time.time()
    rbf_network(Py_X, Py_beta, Py_theta)
    tiempoPy = time.time() - inicio
    pTiempoPy.append(tiempoPy)

    inicio = time.time()
    Cy_rbf_network(Py_X, Py_beta, Py_theta)
    tiempoCy = time.time() - inicio
    pTiempoCy.append(tiempoCy)

    speedUp = round(tiempoPy / tiempoCy, 3)
    pSpeedUp.append(speedUp)

promPy = round(sum(pTiempoPy) / len(pTiempoPy), 3)
promCy = round(sum(pTiempoCy) / len(pTiempoCy), 3)
promSpeedUp = round(sum(pSpeedUp) / len(pSpeedUp), 3)
import functionE
import cy_functionE
import numpy as np
import time

D = 5
N = 1500
X = np.array([np.random.rand(N) for d in range(D)]).T
beta = np.random.rand(N)
theta = 10

start = time.time()
functionE.rbf_network(X, beta, theta)

total_time = time.time() - start

start = time.time()
cy_functionE.rbf_network(X, beta, theta)
cy_total_time = time.time() - start

speedUp = round(total_time / cy_total_time, 3)
print(f"Python time: {total_time} \n")
print(f"Cython time: {cy_total_time} \n")
print(f"SpeedUp: {speedUp} \n")
Example #5
0
"""

from functionE import rbf_network
import cy_functionE
import numpy as np
import matplotlib.pyplot as plt
import time

D = 5
N = 1500
X = np.array([np.random.rand(N) for d in range(D)]).T
beta = np.random.rand(N)
theta = 10

inicio = time.time()
rbf_network(X, beta, theta)
tiempoPy = time.time() - inicio

inicio = time.time()
cy_functionE.rbf_network(X, beta, theta)
tiempoCy = time.time() - inicio

speedUp = round(tiempoPy / tiempoCy, 3)

print(f'Tiempo python : {tiempoPy}\n')
print(f'Tiempo Cython: {tiempoCy}\n')
print("SpeedUp: {}\n".format(speedUp))

fig, ax = plt.subplots()
etiquetas = ["Tiempo python", "Tiempo Cython"]
tiempos = [tiempoPy, tiempoCy]
Example #6
0
## Ingenieria de sistemas y telecomunicaciones
## Autor: Michael Steven Pinilla Mateus

import functionE
import Cy_functionE
import numpy as np
import time

### Inicializar variebles
D = 5
N = 1500
X = np.array([np.random.rand(N) for d in range(D)]).T
beta = np.random.rand(N)
theta = 10

### Tiempos
inicio = time.time()
result = functionE.rbf_network(X, beta, theta)
tiempoPy = time.time() - inicio
#print(result)

inicio = time.time()
result = Cy_functionE.rbf_network(X, beta, theta)
tiempoCy = time.time() - inicio
#print(np.asarray(result))

speedUp = round(tiempoPy / tiempoCy, 3)

print("Tiempo Python: {} \n".format(tiempoPy))
print("Tiempo Cython: {} \n".format(tiempoCy))
print("SpeedUp: {} \n".format(speedUp))