<jupyter_start><jupyter_text>GF(2^m) speed tests<jupyter_code>import numpy as np
import galois
GF = galois.GF(2**13)
print(GF.properties)
modes = GF.ufunc_modes
targets = GF.ufunc_targets
targets.remove("cuda")  # Can't test with a GPU on my machine
print(modes)
print(targets)
def speed_test(GF, N):
    a = GF.Random(N)
    b = GF.Random(N, low=1)

    for operation in [np.add, np.multiply]:
        print(f"Operation: {operation.__name__}")
        for target in targets:
            for mode in modes:
                GF.compile(mode, target)
                print(f"Target: {target}, Mode: {mode}", end="\n    ")
                %timeit operation(a, b)
        print()

    for operation in [np.reciprocal, np.log]:
        print(f"Operation: {operation.__name__}")
        for target in targets:
            for mode in modes:
                GF.compile(mode, target)
                print(f"Target: {target}, Mode: {mode}", end="\n    ")
                %timeit operation(b)
        print()<jupyter_output><empty_output><jupyter_text>N = 10k<jupyter_code>speed_test(GF, 10_000)<jupyter_output>Operation: add
Target: cpu, Mode: jit-lookup
    188 µs ± 23.9 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Target: cpu, Mode: jit-calculate
    95.6 µs ± 11.2 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Target: parallel, Mode: jit-lookup
    61.4 ms ± 4.82 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Target: parallel, Mode: jit-calculate
    61.8 ms ± 6.03 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Operation: multiply
Target: cpu, Mode: jit-lookup
    148 µs ± 10.5 µs per loop (mean ± std. dev. of 7 runs, 10000 loops each)
Target: cpu, Mode: jit-calculate
    646 µs ± 73.4 µs per loop (mean ± std. dev. of 7 runs, 1000 loops each)
Target: parallel, Mode: jit-lookup
    59.4 ms ± 4.54 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)
Target: parallel, Mode: jit-calculate
    59.9 ms ± 4.29 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

Operation: reciprocal
Target: cpu, Mode: jit-lookup
    113 µs ± 7.92 µs per loop (m[...]
{'fraction_non_alphanumeric': 0.12345679012345678, 'fraction_numerical': 0.04748338081671415, 'mean_word_length': 2.690017513134851, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 8, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '229979', 'license': 'MIT', 'n_tokens_mistral': 830, 'n_tokens_neox': 724, 'n_words': 272, 'path': 'docs/pages/notebooks/speed_test_gf2m.ipynb', 'repo_name': 'Werni2A/galois', 'size': '2106'}