<jupyter_start><jupyter_text>Performance Test This notebook performs speed tests on the module `qm` for when Numba is used and when it is not. Depending on the type of computer and the libraries installed, the performance of Numba will vary. If it turns out that using Numba is slowing things down, go to the subfolder `./qm` and delete `qm_numba.py`.<jupyter_code>import qm.qm as module1
try:
    import qm.qm_numba as module2
except:
    pass

from time import perf_counter
import numpy as np
import matplotlib.pyplot as plt

def test(module):
    x = np.linspace(-0.5, 0.5, 512)
        
    print("Time of ... ")
    print("constructing U(t):")
    time_list = []

    for _ in range (1):
        t1 = perf_counter()
        U = module.UnitaryOperator1D(x**2)
        t2 = perf_counter()
        time_list.append(t2-t1)

    print(sum(time_list)/len(time_list))
      
    def gauss(x, sigma):
        u = np.array([xi/sigma for xi in x], np.complex128)
        return np.exp(-0.5*u**2)

    psi = module.Wavefunction1D(gauss(x-0.25,0.1))
      
    print("evolving wavefunction 1000 times:")
    t1 = perf_counter()
    for _ in range (1000):
        U(psi)
    t2 = perf_counter()
    print(t2 - t1)
        
    print("computing eigenvectors and eigenvalues:")
    t1 = perf_counter()
    U.set_energy_eigenstates() 
    t2 = perf_counter()
    print(t2 - t1)
      
    plt.title("Wavefunction in SHO")
    plt.plot(x, np.real(psi.x), label = "Re($\psi(x)$)")
    plt.plot(x, np.imag(psi.x), label = "Im($\psi(x)$)")
    plt.plot(x, np.abs(psi.x), label = "$|\psi(x)|$", color="black")
    plt.legend()
    plt.xlabel("x (Natural Units)")
    plt.grid()
      
    plt.show()
    plt.close()<jupyter_output><empty_output><jupyter_text>Here are the performance stats without Numba:<jupyter_code>test(module1)<jupyter_output><empty_output><jupyter_text>Here are the performance stats with Numba:<jupyter_code>test(module2)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.1317671092951992, 'fraction_numerical': 0.02349336057201226, 'mean_word_length': 3.1504237288135593, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '430131', 'license': 'MIT', 'n_tokens_mistral': 738, 'n_tokens_neox': 703, 'n_words': 176, 'path': 'performance_test.ipynb', 'repo_name': 'marl0ny/1D-Time-Independent-Quantum-Mechanics-Applet-Using-Python-and-Tkinter', 'size': '1958'}