From 53a6bfebe914e47b2f006e0ff1cbc7b2435b9470 Mon Sep 17 00:00:00 2001 From: chortas Date: Mon, 24 Jan 2022 18:19:17 -0300 Subject: [PATCH 1/4] Change tolerance test --- tests/stages/generation/test.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/stages/generation/test.py b/tests/stages/generation/test.py index 94118b1..5158d78 100644 --- a/tests/stages/generation/test.py +++ b/tests/stages/generation/test.py @@ -37,8 +37,7 @@ def generate(N): def test(N): k = generate(N) k_correct = np.load(f"out_{N}.npy") - comparison = k == k_correct - return comparison.all() + return np.allclose(k, k_correct, rtol=1e-10, atol=1e-10) class TestGeneration(unittest.TestCase): def test_8(self): From e804201f10e3291e789f7a5f2b7f9a6fdd989418 Mon Sep 17 00:00:00 2001 From: chortas Date: Mon, 24 Jan 2022 18:44:38 -0300 Subject: [PATCH 2/4] Delete core variable in generation file --- tools/generation/fftma_gen.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tools/generation/fftma_gen.py b/tools/generation/fftma_gen.py index 2e5d288..752fec1 100755 --- a/tools/generation/fftma_gen.py +++ b/tools/generation/fftma_gen.py @@ -207,8 +207,7 @@ def genGaussK( 0, ) # coord des vecteurs de base (1 0 0) y (0 1 0) k = gen( - Nx, Ny, Nz, dx, dy, dz, seed, [v1], 0, 1, 0, 8 #TODO: change this harcoded value - ) # 0, 1, 0 = mean, variance, typ #Generation of a correlated standard dsitribution N(0,1) + Nx, Ny, Nz, dx, dy, dz, seed, [v1], 0, 1, 0) # 0, 1, 0 = mean, variance, typ #Generation of a correlated standard dsitribution N(0,1) return k From 5ae4e0a28df716365ef386ce62ec85061797b453 Mon Sep 17 00:00:00 2001 From: chortas Date: Mon, 24 Jan 2022 18:49:05 -0300 Subject: [PATCH 3/4] Add extra tests to README --- README.md | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f19a670..05cd122 100644 --- a/README.md +++ b/README.md @@ -18,18 +18,32 @@ make binaries make run ``` -## Correr los casos de prueba +## Pruebas de integración ``` make test ``` +## Pruebas unitarias + +### Generacion + +``` +make test-gen +``` + ## Correr las pruebas de performance ``` make perf ``` +### Obtener tiempos de generacion + +``` +make time-gen N= +``` + ## Instalar el binario FFTMA ``` @@ -44,4 +58,3 @@ El sistema actualmente se encuentra migrado a Python3 por lo que no se recomiend ./script_install_py2.sh ``` - From 8113f714de5edbd8b75b5f76d8a433b9be5cc0d2 Mon Sep 17 00:00:00 2001 From: chortas Date: Mon, 24 Jan 2022 18:59:41 -0300 Subject: [PATCH 4/4] Add rule to makefile time-gen and time.py file --- Makefile | 5 ++- tests/performance/generation/time.py | 56 ++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 tests/performance/generation/time.py diff --git a/Makefile b/Makefile index 876955e..b4742c9 100644 --- a/Makefile +++ b/Makefile @@ -19,4 +19,7 @@ perf: binaries cd tests/performance && python3 connectivity.py test-gen: fftma - cd tests/stages/generation && python3 -m unittest test.py \ No newline at end of file + cd tests/stages/generation && python3 -m unittest test.py + +time-gen: fftma + cd tests/performance/generation && python3 time.py $(N) \ No newline at end of file diff --git a/tests/performance/generation/time.py b/tests/performance/generation/time.py new file mode 100644 index 0000000..19eb542 --- /dev/null +++ b/tests/performance/generation/time.py @@ -0,0 +1,56 @@ +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) + + duration = time.time() - start_time + return k, duration + +N=int(sys.argv[1]) +SAMPLE_SIZE=100 + +def time_measurement(n, sample_size): + sample = [] + + print(f"SAMPLE_SIZE = {SAMPLE_SIZE}") + for i in range(sample_size): + _, duration = generate(n) + print(i) + sample.append(duration) + + npsample = np.array(sample) + + print(f"AVG: {np.mean(npsample)} seconds") + print(f"MEDIAN: {np.median(npsample)} seconds") + +time_measurement(N, SAMPLE_SIZE) \ No newline at end of file