diff --git a/tests/performance/generation/time.py b/tests/performance/generation/time.py new file mode 100644 index 0000000..024bdbb --- /dev/null +++ b/tests/performance/generation/time.py @@ -0,0 +1,55 @@ +import numpy as np +#from tests.utils.gen_sample import generate + +import sys + +from FFTMA import gen +import time + +def generate(N): + start_time = time.time() + nx, ny, nz = N,N,N + dx, dy, dz = 1.0, 1.0, 1.0 + seed= 1548762 #rdi(10000,99999) + var=1 + vario=2 + alpha=1 + lcx=2 + lcy=4 + lcz=16 + ap1x=1 + ap1y=0 + ap1z=0 + ap2x=0 + ap2y=1 + ap2z=0 + + v1 = (var, vario, alpha, lcx, lcy, lcz, ap1x, ap1y, ap1z, ap2x, ap2y, ap2z) + variograms = [v1] + + mean=15.3245987 + variance=3.5682389 + typ=3 + + k = gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ, 8) + + duration = time.time() - start_time + return k, duration + +N=int(sys.argv[1]) +SAMPLE_SIZE=1000 + +def time_measurement(n, sample_size): + sample = [] + + for i in range(sample_size): + _, duration = generate(n) + print(i) + sample.append(duration) + + npsample = np.array(sample) + + print(np.mean(npsample)) + print(np.median(npsample)) + +time_measurement(N, SAMPLE_SIZE) \ No newline at end of file diff --git a/tests/stages/generation/out_16.npy b/tests/stages/generation/out_16.npy new file mode 100644 index 0000000..7502530 Binary files /dev/null and b/tests/stages/generation/out_16.npy differ diff --git a/tests/stages/generation/out_32.npy b/tests/stages/generation/out_32.npy new file mode 100644 index 0000000..609251e Binary files /dev/null and b/tests/stages/generation/out_32.npy differ diff --git a/tests/stages/generation/out_64.npy b/tests/stages/generation/out_64.npy new file mode 100644 index 0000000..05c2c8a Binary files /dev/null and b/tests/stages/generation/out_64.npy differ diff --git a/tests/stages/generation/out_8.npy b/tests/stages/generation/out_8.npy new file mode 100644 index 0000000..03ee9a1 Binary files /dev/null and b/tests/stages/generation/out_8.npy differ diff --git a/tests/stages/generation/test.py b/tests/stages/generation/test.py new file mode 100644 index 0000000..73dbc8d --- /dev/null +++ b/tests/stages/generation/test.py @@ -0,0 +1,54 @@ + +import numpy as np +import unittest +from FFTMA import gen +import time + +def generate(N): + start_time = time.time() + nx, ny, nz = N,N,N + dx, dy, dz = 1.0, 1.0, 1.0 + seed= 1548762 #rdi(10000,99999) + var=1 + vario=2 + alpha=1 + lcx=2 + lcy=4 + lcz=16 + ap1x=1 + ap1y=0 + ap1z=0 + ap2x=0 + ap2y=1 + ap2z=0 + + v1 = (var, vario, alpha, lcx, lcy, lcz, ap1x, ap1y, ap1z, ap2x, ap2y, ap2z) + variograms = [v1] + + mean=15.3245987 + variance=3.5682389 + typ=3 + + k = gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ, 8) + + duration = time.time() - start_time + return k, duration + +def test(N): + k, duration = generate(N) + k_correct = np.load(f"out_{N}.npy") + print(f"Generation with N = {N} time = {duration}s") + return np.allclose(k, k_correct, rtol=1e-10, atol=1e-10) + +class TestGeneration(unittest.TestCase): + def test_08(self): + self.assertTrue(test(8)) + + def test_16(self): + self.assertTrue(test(16)) + + def test_32(self): + self.assertTrue(test(32)) + + def test_64(self): + self.assertTrue(test(64)) \ No newline at end of file diff --git a/tests/utils/gen_sample.py b/tests/utils/gen_sample.py new file mode 100644 index 0000000..2c11992 --- /dev/null +++ b/tests/utils/gen_sample.py @@ -0,0 +1,32 @@ +from FFTMA import gen +import time + +def generate(N): + start_time = time.time() + nx, ny, nz = N,N,N + dx, dy, dz = 1.0, 1.0, 1.0 + seed= 1548762 #rdi(10000,99999) + var=1 + vario=2 + alpha=1 + lcx=2 + lcy=4 + lcz=16 + ap1x=1 + ap1y=0 + ap1z=0 + ap2x=0 + ap2y=1 + ap2z=0 + + v1 = (var, vario, alpha, lcx, lcy, lcz, ap1x, ap1y, ap1z, ap2x, ap2y, ap2z) + variograms = [v1] + + mean=15.3245987 + variance=3.5682389 + typ=3 + + k = gen(nx, ny, nz, dx, dy, dz, seed, variograms, mean, variance, typ) + + duration = time.time() - start_time + return k, duration \ No newline at end of file