From a48e7b6ed2b7d23e335a95f5e8257dfcd4ffe6f5 Mon Sep 17 00:00:00 2001 From: y00314596 Date: Wed, 10 Aug 2022 18:04:23 +0800 Subject: [PATCH] add by yangqing3@huawei.com Signed-off-by: y00314596 --- .../perf/perfjs/src/main/js/test/Perf.test.js | 160 ++++++++++++++++++ 1 file changed, 160 insertions(+) diff --git a/global/perf/perfjs/src/main/js/test/Perf.test.js b/global/perf/perfjs/src/main/js/test/Perf.test.js index 11a80db37..7cac3f8b2 100644 --- a/global/perf/perfjs/src/main/js/test/Perf.test.js +++ b/global/perf/perfjs/src/main/js/test/Perf.test.js @@ -2196,5 +2196,165 @@ describe('PerfTest', function () { } }) + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9000 + * @tc.name test the performance of getLocationName + * @tc.desc check the performance of getLocationName + */ + it('perf_test_9000', 0, function () { + console.log('perf_test_9000 ' + 'start'); + let phonenumber = new I18n.PhoneNumberFormat('CN'); + let ran = Math.ceil(Math.random(1) * 9); + console.log('perf_test_9000 ' + ran); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = phonenumber.getLocationName('1351057467' + ran, 'zh-CN'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9000--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + expect(value).assertEqual('广东省深圳市'); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9100 + * @tc.name test the performance of getUsingLocalDigit + * @tc.desc check the performance of getUsingLocalDigit + */ + it('perf_test_9100', 0, function () { + console.log('perf_test_9100 ' + 'start'); + let value = true; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.getUsingLocalDigit(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9100--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9200 + * @tc.name test the performance of timezone.getAvailableIDs + * @tc.desc check the performance of timezone.getAvailableIDs + */ + it('perf_test_9200', 0, function () { + console.log('perf_test_9200 ' + 'start'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.TimeZone.getAvailableIDs(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9200--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9300 + * @tc.name test the performance of getAvailableZoneCityIDs + * @tc.desc check the performance of getAvailableZoneCityIDs + */ + it('perf_test_9300', 0, function () { + console.log('perf_test_9300 ' + 'start'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.TimeZone.getAvailableZoneCityIDs(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9300--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9400 + * @tc.name test the performance of getCityDisplayName + * @tc.desc check the performance of getCityDisplayName + */ + it('perf_test_9400', 0, function () { + console.log('perf_test_9400 ' + 'start'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.TimeZone.getCityDisplayName('Auckland', 'zh'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9400--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_9500 + * @tc.name test the performance of getTimezoneFromCity + * @tc.desc check the performance of getTimezoneFromCity + */ + it('perf_test_9500', 0, function () { + console.log('perf_test_9500 ' + 'start'); + let value = 'test'; + let startTime = new Date().getTime(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.TimeZone.getTimezoneFromCity('Auckland'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_9500--' + + ' value: ' + value + + ' exeTime: ' + exeTime + + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + console.log('*************end PerfTest*************'); })} -- GitLab