Skip to content

Commit e8626e7

Browse files
perf tests
1 parent 98d367b commit e8626e7

File tree

4 files changed

+68
-84
lines changed

4 files changed

+68
-84
lines changed

products/nativescript/perf_helpers.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
from core.utils.gradle import Gradle
77
from core.utils.json_utils import JsonUtils
88
from core.utils.npm import Npm
9+
from core.utils.perf_utils import PerfUtils
910
from core.utils.xcode import Xcode
1011
from data.changes import Sync
1112
from products.nativescript.tns import Tns
1213

1314
RETRY_COUNT = 3
15+
TOLERANCE = 0.20
1416
APP_NAME = Settings.AppName.DEFAULT
1517
EXPECTED_RESULTS = JsonUtils.read(os.path.join(Settings.TEST_RUN_HOME, 'tests', 'perf', 'data.json'))
1618

@@ -79,3 +81,48 @@ def get_actual_result(template, platform, entry):
7981
def get_expected_result(template, platform, entry):
8082
platform = str(platform)
8183
return EXPECTED_RESULTS[template][platform][entry]
84+
85+
@staticmethod
86+
def prepare_data(template, template_package, change_set):
87+
android_result_file = Helpers.get_result_file_name(template, Platform.ANDROID)
88+
ios_result_file = Helpers.get_result_file_name(template, Platform.IOS)
89+
Helpers.prepare_and_build(template=template_package, platform=Platform.ANDROID,
90+
change_set=change_set, result_file=android_result_file)
91+
Helpers.prepare_and_build(template=template_package, platform=Platform.IOS,
92+
change_set=change_set, result_file=ios_result_file)
93+
94+
@staticmethod
95+
def prepare_android_initial(template):
96+
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'prepare_initial')
97+
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'prepare_initial')
98+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android prepare time is not OK.'
99+
100+
@staticmethod
101+
def prepare_ios_initial(template):
102+
actual = Helpers.get_actual_result(template, Platform.IOS, 'prepare_initial')
103+
expected = Helpers.get_expected_result(template, Platform.IOS, 'prepare_initial')
104+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios prepare time is not OK.'
105+
106+
@staticmethod
107+
def build_android_initial(template):
108+
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_initial')
109+
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_initial')
110+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android build time is not OK.'
111+
112+
@staticmethod
113+
def build_ios_initial(template):
114+
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_initial')
115+
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_initial')
116+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios build time is not OK.'
117+
118+
@staticmethod
119+
def build_android_incremental(template):
120+
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_incremental')
121+
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_incremental')
122+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental android build time is not OK.'
123+
124+
@staticmethod
125+
def build_ios_incremental(template):
126+
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_incremental')
127+
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_incremental')
128+
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental ios build time is not OK.'

tests/perf/tooling/build_perf_hello_world_js.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77

88
from core.base_test.tns_test import TnsTest
99
from core.enums.os_type import OSType
10-
from core.enums.platform_type import Platform
1110
from core.settings import Settings
12-
from core.utils.perf_utils import PerfUtils
1311
from data.changes import Changes
1412
from data.templates import Template
1513
from products.nativescript.perf_helpers import Helpers
1614

17-
TOLERANCE = 0.20
18-
1915

2016
# noinspection PyMethodMayBeStatic,PyUnusedLocal
2117
class PrepareAndBuildPerfTests(TnsTest):
@@ -36,48 +32,31 @@ def tearDownClass(cls):
3632

3733
@parameterized.expand(TEST_DATA)
3834
def test_001_prepare_data(self, template, template_package, change_set):
39-
android_result_file = Helpers.get_result_file_name(template, Platform.ANDROID)
40-
ios_result_file = Helpers.get_result_file_name(template, Platform.IOS)
41-
Helpers.prepare_and_build(template=template_package, platform=Platform.ANDROID,
42-
change_set=change_set, result_file=android_result_file)
43-
Helpers.prepare_and_build(template=template_package, platform=Platform.IOS,
44-
change_set=change_set, result_file=ios_result_file)
35+
Helpers.prepare_data(template, template_package, change_set)
4536

4637
@parameterized.expand(TEST_DATA)
4738
def test_200_prepare_android_initial(self, template, template_package, change_set):
48-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'prepare_initial')
49-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'prepare_initial')
50-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android prepare time is not OK.'
39+
Helpers.prepare_android_initial(template)
5140

5241
@parameterized.expand(TEST_DATA)
5342
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
5443
def test_201_prepare_ios_initial(self, template, template_package, change_set):
55-
actual = Helpers.get_actual_result(template, Platform.IOS, 'prepare_initial')
56-
expected = Helpers.get_expected_result(template, Platform.IOS, 'prepare_initial')
57-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios prepare time is not OK.'
44+
Helpers.prepare_ios_initial(template)
5845

5946
@parameterized.expand(TEST_DATA)
6047
def test_300_build_android_initial(self, template, template_package, change_set):
61-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_initial')
62-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_initial')
63-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android build time is not OK.'
48+
Helpers.build_android_initial(template)
6449

6550
@parameterized.expand(TEST_DATA)
6651
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
6752
def test_301_build_ios_initial(self, template, template_package, change_set):
68-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_initial')
69-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_initial')
70-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios build time is not OK.'
53+
Helpers.build_ios_initial(template)
7154

7255
@parameterized.expand(TEST_DATA)
7356
def test_310_build_android_incremental(self, template, template_package, change_set):
74-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_incremental')
75-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_incremental')
76-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental android build time is not OK.'
57+
Helpers.build_android_incremental(template)
7758

7859
@parameterized.expand(TEST_DATA)
7960
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
8061
def test_311_build_ios_incremental(self, template, template_package, change_set):
81-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_incremental')
82-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_incremental')
83-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental ios build time is not OK.'
62+
Helpers.build_ios_incremental(template)

tests/perf/tooling/build_perf_hello_world_ng.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77

88
from core.base_test.tns_test import TnsTest
99
from core.enums.os_type import OSType
10-
from core.enums.platform_type import Platform
1110
from core.settings import Settings
12-
from core.utils.perf_utils import PerfUtils
1311
from data.changes import Changes
1412
from data.templates import Template
1513
from products.nativescript.perf_helpers import Helpers
1614

17-
TOLERANCE = 0.20
18-
1915

2016
# noinspection PyMethodMayBeStatic,PyUnusedLocal
2117
class PrepareAndBuildPerfTests(TnsTest):
@@ -36,48 +32,31 @@ def tearDownClass(cls):
3632

3733
@parameterized.expand(TEST_DATA)
3834
def test_001_prepare_data(self, template, template_package, change_set):
39-
android_result_file = Helpers.get_result_file_name(template, Platform.ANDROID)
40-
ios_result_file = Helpers.get_result_file_name(template, Platform.IOS)
41-
Helpers.prepare_and_build(template=template_package, platform=Platform.ANDROID,
42-
change_set=change_set, result_file=android_result_file)
43-
Helpers.prepare_and_build(template=template_package, platform=Platform.IOS,
44-
change_set=change_set, result_file=ios_result_file)
35+
Helpers.prepare_data(template, template_package, change_set)
4536

4637
@parameterized.expand(TEST_DATA)
4738
def test_200_prepare_android_initial(self, template, template_package, change_set):
48-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'prepare_initial')
49-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'prepare_initial')
50-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android prepare time is not OK.'
39+
Helpers.prepare_android_initial(template)
5140

5241
@parameterized.expand(TEST_DATA)
5342
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
5443
def test_201_prepare_ios_initial(self, template, template_package, change_set):
55-
actual = Helpers.get_actual_result(template, Platform.IOS, 'prepare_initial')
56-
expected = Helpers.get_expected_result(template, Platform.IOS, 'prepare_initial')
57-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios prepare time is not OK.'
44+
Helpers.prepare_ios_initial(template)
5845

5946
@parameterized.expand(TEST_DATA)
6047
def test_300_build_android_initial(self, template, template_package, change_set):
61-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_initial')
62-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_initial')
63-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android build time is not OK.'
48+
Helpers.build_android_initial(template)
6449

6550
@parameterized.expand(TEST_DATA)
6651
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
6752
def test_301_build_ios_initial(self, template, template_package, change_set):
68-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_initial')
69-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_initial')
70-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios build time is not OK.'
53+
Helpers.build_ios_initial(template)
7154

7255
@parameterized.expand(TEST_DATA)
7356
def test_310_build_android_incremental(self, template, template_package, change_set):
74-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_incremental')
75-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_incremental')
76-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental android build time is not OK.'
57+
Helpers.build_android_incremental(template)
7758

7859
@parameterized.expand(TEST_DATA)
7960
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
8061
def test_311_build_ios_incremental(self, template, template_package, change_set):
81-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_incremental')
82-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_incremental')
83-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental ios build time is not OK.'
62+
Helpers.build_ios_incremental(template)

tests/perf/tooling/build_perf_master_detail_ng.py

Lines changed: 7 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,11 @@
77

88
from core.base_test.tns_test import TnsTest
99
from core.enums.os_type import OSType
10-
from core.enums.platform_type import Platform
1110
from core.settings import Settings
12-
from core.utils.perf_utils import PerfUtils
1311
from data.changes import Changes
1412
from data.templates import Template
1513
from products.nativescript.perf_helpers import Helpers
1614

17-
TOLERANCE = 0.20
18-
1915

2016
# noinspection PyMethodMayBeStatic,PyUnusedLocal
2117
class PrepareAndBuildPerfTests(TnsTest):
@@ -36,48 +32,31 @@ def tearDownClass(cls):
3632

3733
@parameterized.expand(TEST_DATA)
3834
def test_001_prepare_data(self, template, template_package, change_set):
39-
android_result_file = Helpers.get_result_file_name(template, Platform.ANDROID)
40-
ios_result_file = Helpers.get_result_file_name(template, Platform.IOS)
41-
Helpers.prepare_and_build(template=template_package, platform=Platform.ANDROID,
42-
change_set=change_set, result_file=android_result_file)
43-
Helpers.prepare_and_build(template=template_package, platform=Platform.IOS,
44-
change_set=change_set, result_file=ios_result_file)
35+
Helpers.prepare_data(template, template_package, change_set)
4536

4637
@parameterized.expand(TEST_DATA)
4738
def test_200_prepare_android_initial(self, template, template_package, change_set):
48-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'prepare_initial')
49-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'prepare_initial')
50-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android prepare time is not OK.'
39+
Helpers.prepare_android_initial(template)
5140

5241
@parameterized.expand(TEST_DATA)
5342
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
5443
def test_201_prepare_ios_initial(self, template, template_package, change_set):
55-
actual = Helpers.get_actual_result(template, Platform.IOS, 'prepare_initial')
56-
expected = Helpers.get_expected_result(template, Platform.IOS, 'prepare_initial')
57-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios prepare time is not OK.'
44+
Helpers.prepare_ios_initial(template)
5845

5946
@parameterized.expand(TEST_DATA)
6047
def test_300_build_android_initial(self, template, template_package, change_set):
61-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_initial')
62-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_initial')
63-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial android build time is not OK.'
48+
Helpers.build_android_initial(template)
6449

6550
@parameterized.expand(TEST_DATA)
6651
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
6752
def test_301_build_ios_initial(self, template, template_package, change_set):
68-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_initial')
69-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_initial')
70-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Initial ios build time is not OK.'
53+
Helpers.build_ios_initial(template)
7154

7255
@parameterized.expand(TEST_DATA)
7356
def test_310_build_android_incremental(self, template, template_package, change_set):
74-
actual = Helpers.get_actual_result(template, Platform.ANDROID, 'build_incremental')
75-
expected = Helpers.get_expected_result(template, Platform.ANDROID, 'build_incremental')
76-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental android build time is not OK.'
57+
Helpers.build_android_incremental(template)
7758

7859
@parameterized.expand(TEST_DATA)
7960
@unittest.skipIf(Settings.HOST_OS != OSType.OSX, 'iOS tests can be executed only on macOS.')
8061
def test_311_build_ios_incremental(self, template, template_package, change_set):
81-
actual = Helpers.get_actual_result(template, Platform.IOS, 'build_incremental')
82-
expected = Helpers.get_expected_result(template, Platform.IOS, 'build_incremental')
83-
assert PerfUtils.is_value_in_range(actual, expected, TOLERANCE), 'Incremental ios build time is not OK.'
62+
Helpers.build_ios_incremental(template)

0 commit comments

Comments
 (0)