From 487116f99a15cca0eb05af13b1280f8a5ddd5129 Mon Sep 17 00:00:00 2001 From: Ray Matsumoto Date: Tue, 27 Apr 2021 20:06:51 -0400 Subject: [PATCH 1/3] Add performance tests for writers --- gmso/tests/base_test.py | 2 +- gmso/tests/test_performance.py | 40 ++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 gmso/tests/test_performance.py diff --git a/gmso/tests/base_test.py b/gmso/tests/base_test.py index 8e66a7318..6b8ccd431 100644 --- a/gmso/tests/base_test.py +++ b/gmso/tests/base_test.py @@ -61,7 +61,7 @@ def _topology(n_sites=100): packed_system = mb.fill_box( compound=ar, n_compounds=n_sites, - box=mb.Box([3, 3, 3]), + density=1700, ) return packed_system diff --git a/gmso/tests/test_performance.py b/gmso/tests/test_performance.py new file mode 100644 index 000000000..3eafb9fb7 --- /dev/null +++ b/gmso/tests/test_performance.py @@ -0,0 +1,40 @@ +import pytest + +from gmso.core.atom_type import AtomType +from gmso.core.atom import Atom +from gmso.core.topology import Topology +from gmso.tests.base_test import BaseTest +from gmso.formats.lammpsdata import write_lammpsdata +from gmso.formats.gro import write_gro +from gmso.formats.mcf import write_mcf +from gmso.formats.xyz import write_xyz +from gmso.formats.top import write_top +from gmso.external import from_mbuild + +class TestPerformance(BaseTest): + @pytest.mark.timeout(15) + def test_lammps_performance(self, n_typed_ar_system): + top = n_typed_ar_system(n_sites=10000) + write_lammpsdata(top, "data.ar") + + @pytest.mark.timeout(15) + def test_mcf_performance(self, n_typed_ar_system): + top = n_typed_ar_system(n_sites=10000) + write_mcf(top, "ar.mcf") + + @pytest.mark.timeout(15) + def test_top_performance(self, n_typed_ar_system): + top = n_typed_ar_system(n_sites=10000) + write_top(top, "ar.top") + + @pytest.mark.timeout(5) + def test_xyz_performance(self, n_ar_system): + cmpd = n_ar_system(n_sites=10000) + top = from_mbuild(cmpd) + write_xyz(top, "ar.xyz") + + @pytest.mark.timeout(5) + def test_gro_performance(self, n_ar_system): + cmpd = n_ar_system(n_sites=10000) + top = from_mbuild(cmpd) + write_gro(top, "ar.gro") From 595f774a935d3261c9d77cb267f3fd256593e7ad Mon Sep 17 00:00:00 2001 From: Ray Matsumoto Date: Tue, 27 Apr 2021 20:19:10 -0400 Subject: [PATCH 2/3] Add test to check from_mbuild performance --- gmso/tests/test_performance.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gmso/tests/test_performance.py b/gmso/tests/test_performance.py index 3eafb9fb7..3970dfb07 100644 --- a/gmso/tests/test_performance.py +++ b/gmso/tests/test_performance.py @@ -38,3 +38,10 @@ def test_gro_performance(self, n_ar_system): cmpd = n_ar_system(n_sites=10000) top = from_mbuild(cmpd) write_gro(top, "ar.gro") + + #TODO: Add test to check performance of loading in XML when more performant + + @pytest.mark.timeout(20) + def test_from_mbuild_performance(self, n_ar_system): + cmpd = n_ar_system(n_sites=50000) + top = from_mbuild(cmpd) From 0aa3c87c8e01b7a641c9888c270719f37ee2c680 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Tue, 15 Jun 2021 21:26:18 +0000 Subject: [PATCH 3/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- gmso/tests/test_performance.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/gmso/tests/test_performance.py b/gmso/tests/test_performance.py index 3970dfb07..c5d5a021a 100644 --- a/gmso/tests/test_performance.py +++ b/gmso/tests/test_performance.py @@ -1,15 +1,16 @@ import pytest -from gmso.core.atom_type import AtomType from gmso.core.atom import Atom +from gmso.core.atom_type import AtomType from gmso.core.topology import Topology -from gmso.tests.base_test import BaseTest -from gmso.formats.lammpsdata import write_lammpsdata +from gmso.external import from_mbuild from gmso.formats.gro import write_gro +from gmso.formats.lammpsdata import write_lammpsdata from gmso.formats.mcf import write_mcf -from gmso.formats.xyz import write_xyz from gmso.formats.top import write_top -from gmso.external import from_mbuild +from gmso.formats.xyz import write_xyz +from gmso.tests.base_test import BaseTest + class TestPerformance(BaseTest): @pytest.mark.timeout(15) @@ -30,18 +31,18 @@ def test_top_performance(self, n_typed_ar_system): @pytest.mark.timeout(5) def test_xyz_performance(self, n_ar_system): cmpd = n_ar_system(n_sites=10000) - top = from_mbuild(cmpd) + top = from_mbuild(cmpd) write_xyz(top, "ar.xyz") @pytest.mark.timeout(5) def test_gro_performance(self, n_ar_system): cmpd = n_ar_system(n_sites=10000) - top = from_mbuild(cmpd) + top = from_mbuild(cmpd) write_gro(top, "ar.gro") - #TODO: Add test to check performance of loading in XML when more performant + # TODO: Add test to check performance of loading in XML when more performant @pytest.mark.timeout(20) def test_from_mbuild_performance(self, n_ar_system): cmpd = n_ar_system(n_sites=50000) - top = from_mbuild(cmpd) + top = from_mbuild(cmpd)