From bb9b50de6335496f9f1c9f747ecd62bb4c8a0d6c Mon Sep 17 00:00:00 2001 From: y00314596 Date: Tue, 1 Mar 2022 11:07:08 +0800 Subject: [PATCH] add by yangqing3@huawei.com Signed-off-by: y00314596 --- global/BUILD.gn | 1 + .../src/main/js/default/test/Perf.test.js | 230 ++++++++++++++++++ 2 files changed, 231 insertions(+) diff --git a/global/BUILD.gn b/global/BUILD.gn index d31c74b03..7f1b9096f 100755 --- a/global/BUILD.gn +++ b/global/BUILD.gn @@ -19,6 +19,7 @@ group("global") { deps = [ "cust/custjs:custjs_test", "i18n_standard/intljs:intljs_test", + "perf/perfjs:perfjs_test", "resmgr_standard/resmgrjs:resmgrjs_test", ] } else { diff --git a/global/perf/perfjs/src/main/js/default/test/Perf.test.js b/global/perf/perfjs/src/main/js/default/test/Perf.test.js index 0dd6f585d..4dbeceb6e 100755 --- a/global/perf/perfjs/src/main/js/default/test/Perf.test.js +++ b/global/perf/perfjs/src/main/js/default/test/Perf.test.js @@ -61,5 +61,235 @@ describe('PerfTest', function () { } }) + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0200 + * @tc.name test the performance of getSystemRegion + * @tc.desc check the performance of getSystemRegion + */ + it('perf_test_0200', 0, function () { + console.log('perf_test_0200 ' + 'start'); + let startTime = new Date().getTime(); + let region = 'test'; + for(let i = 0; i < EXETIME; i++){ + region = I18n.getSystemRegion(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0200--' + 'region: ' + region + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0300 + * @tc.name test the performance of getSystemLocale + * @tc.desc check the performance of getSystemLocale + */ + it('perf_test_0300', 0, function () { + console.log('perf_test_0300 ' + 'start'); + let startTime = new Date().getTime(); + let locale = 'test'; + for(let i = 0; i < EXETIME; i++){ + locale = I18n.getSystemLocale(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0300--' + 'locale: ' + locale + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0400 + * @tc.name test the performance of setSystemLanguage + * @tc.desc check the performance of setSystemLanguage + */ + it('perf_test_0400', 0, function () { + console.log('perf_test_0400 ' + 'start'); + let startTime = new Date().getTime(); + let value = false; + for(let i = 0; i < EXETIME; i++){ + value = I18n.setSystemLanguage('en'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0400--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0500 + * @tc.name test the performance of setSystemRegion + * @tc.desc check the performance of setSystemRegion + */ + it('perf_test_0500', 0, function () { + console.log('perf_test_0500 ' + 'start'); + let startTime = new Date().getTime(); + let value = false; + for(let i = 0; i < EXETIME; i++){ + value = I18n.setSystemRegion('US'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0500--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0600 + * @tc.name test the performance of setSystemLocale + * @tc.desc check the performance of setSystemLocale + */ + it('perf_test_0600', 0, function () { + console.log('perf_test_0600 ' + 'start'); + let startTime = new Date().getTime(); + let value = false; + for(let i = 0; i < EXETIME; i++){ + value = I18n.setSystemLocale('en-Latn-US'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0600--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0700 + * @tc.name test the performance of getSystemLanguages + * @tc.desc check the performance of getSystemLanguages + */ + it('perf_test_0700', 0, function () { + console.log('perf_test_0700 ' + 'start'); + let startTime = new Date().getTime(); + let value = new Array(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.getSystemLanguages(); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0700--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0800 + * @tc.name test the performance of getSystemCountries + * @tc.desc check the performance of getSystemCountries + */ + it('perf_test_0800', 0, function () { + console.log('perf_test_0800 ' + 'start'); + let startTime = new Date().getTime(); + let value = new Array(); + for(let i = 0; i < EXETIME; i++){ + value = I18n.getSystemCountries('en'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0800--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_0900 + * @tc.name test the performance of isSuggested + * @tc.desc check the performance of isSuggested + */ + it('perf_test_0900', 0, function () { + console.log('perf_test_0900 ' + 'start'); + let startTime = new Date().getTime(); + let value = false; + for(let i = 0; i < EXETIME; i++){ + value = I18n.isSuggested('en'); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_0900--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_1000 + * @tc.name test the performance of getDisplayCountry + * @tc.desc check the performance of getDisplayCountry + */ + it('perf_test_1000', 0, function () { + console.log('perf_test_1000 ' + 'start'); + let startTime = new Date().getTime(); + let value = 'test'; + for(let i = 0; i < EXETIME; i++){ + value = I18n.getDisplayCountry('zh-Hans-CN', 'en-US', true); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_1000--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + + /* * + * @tc.number SUB_GLOBAL_PERF_JS_1100 + * @tc.name test the performance of getDisplayLanguage + * @tc.desc check the performance of getDisplayLanguage + */ + it('perf_test_1100', 0, function () { + console.log('perf_test_1100 ' + 'start'); + let startTime = new Date().getTime(); + let value = 'test'; + for(let i = 0; i < EXETIME; i++){ + value = I18n.getDisplayLanguage('zh-Hans-CN', 'en-US', true); + } + let exeTime = new Date().getTime() - startTime; + let avgTime = exeTime/EXETIME; + console.log('perf_test_1100--' + 'value: ' + value + ' exeTime: ' + exeTime + ' avgTime: ' + avgTime); + if(avgTime < 10){ + expect(true).assertTrue(); + } + else{ + expect(false).assertTrue(); + } + }) + console.log('*************end PerfTest*************'); }) \ No newline at end of file -- GitLab