From 1659c3846bad41baba7bdafce81a6c6aac16dcff Mon Sep 17 00:00:00 2001 From: youbing54 Date: Wed, 16 Oct 2024 15:21:03 +0800 Subject: [PATCH] =?UTF-8?q?IssueNo:=20https://gitee.com/openharmony/arkui?= =?UTF-8?q?=5Face=5Fengine=5Flite/issues/IAXIR1=20describe:=20=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=E4=BF=AE=E5=A4=8D:=20performance001Func=E8=B6=85?= =?UTF-8?q?=E5=A4=A7=E5=87=BD=E6=95=B0=E6=95=B4=E6=94=B9=20Feature=20or=20?= =?UTF-8?q?Bugfix:=20Bugfix=20Binary=20Source:Yes=20Signed-off-by:=20youbi?= =?UTF-8?q?ng54?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pages/canvas/indexAPIPerformance/index.js | 242 ++++++++++-------- 1 file changed, 133 insertions(+), 109 deletions(-) diff --git a/test/moduletest/common/test_app/ui_auto_test/src/main/js/default/pages/canvas/indexAPIPerformance/index.js b/test/moduletest/common/test_app/ui_auto_test/src/main/js/default/pages/canvas/indexAPIPerformance/index.js index ce379cfb..e246eb5f 100644 --- a/test/moduletest/common/test_app/ui_auto_test/src/main/js/default/pages/canvas/indexAPIPerformance/index.js +++ b/test/moduletest/common/test_app/ui_auto_test/src/main/js/default/pages/canvas/indexAPIPerformance/index.js @@ -16,114 +16,13 @@ import {routePage} from "../../../common/js/general"; export default { ...routePage("pages/canvas/indexAPI/index"), - performance001Func: function () { - var myDate = new Date(); - var myTime=myDate.toLocaleTimeString(); - var canvasRef = this.$refs.canvas1; - var ctx = canvasRef.getContext("2d"); - console.log("stroke 1 time contains 100 times moveTo+lineTo begin =========" + myTime); - // 画101条线 - var i; - var x = 0; - // 红色 - ctx.strokeStyle = "#FF0000"; - ctx.lineWidth = 5; - for(i = 0; i< 100; i++) { - x = x + 10; - ctx.moveTo(10,x); - ctx.lineTo(30,x); - if(i === 99) { - ctx.stroke(); - console.log("stroke 1 time contains 100 times moveTo+lineTo end =========" + myTime); - ctx.beginPath(); - // 蓝色 - ctx.strokeStyle = "#0000FF"; - ctx.lineWidth = 3; - ctx.moveTo(10,x+10); - ctx.lineTo(30,x+10); - ctx.stroke(); - } - } - - // 画101个矩形 - console.log("stroke 1 time contains 100 times rect begin =========" + myTime); - ctx.beginPath(); - var y = 0; - for(i = 0; i< 100; i++) { - y = y + 10; - ctx.rect(40,y, 20,4); - if(i === 99) { - ctx.stroke(); - console.log("stroke 1 time contains 100 times rect end =========" + myTime); - ctx.beginPath(); - // 红色 - ctx.strokeStyle = "#FF0000"; - ctx.lineWidth = 2; - ctx.rect(40,y+10, 20,4); - ctx.stroke(); - } - } - - // 画101个圆 - console.log("stroke 1 time contains 100 times arc begin =========" + myTime); - ctx.beginPath(); - var z = 0; - for(i = 0; i< 100; i++) { - z = z + 10; - ctx.arc(80,z,5,Math.PI*2*(0/360),Math.PI*2*(90/360),false); - if(i === 99) { - ctx.stroke(); - console.log("stroke 1 time contains 100 times arc end =========" + myTime); - ctx.beginPath(); - // 蓝色 - ctx.strokeStyle = "#0000FF"; - ctx.lineWidth = 2; - ctx.arc(80,z+10,5,Math.PI*2*(0/360),Math.PI*2*(90/360),false); - ctx.stroke(); - } - } - - // 画101条线 - x = 0; - // 红色 - ctx.strokeStyle = "#FF0000"; - ctx.lineWidth = 1; - console.log("stroke 100 times contains 100 times moveTo+lineTo begin =========" + myTime); - for(i = 0; i< 100; i++) { - x = x + 10; - ctx.beginPath(); - ctx.moveTo(100,x); - ctx.lineTo(130,x); - ctx.stroke(); - } - console.log("stroke 100 times contains 100 times moveTo+lineTo end =========" + myTime); - - // 画100个矩形 - y = 0; - // 红色 - ctx.strokeStyle = "#FF0000"; - console.log("stroke 100 times contains 100 times rect begin =========" + myTime); - for(i = 0; i< 100; i++) { - y = y + 10; - ctx.beginPath(); - ctx.rect(140,y, 20,4); - ctx.stroke(); - } - console.log("stroke 100 time contains 100 times rect end =========" + myTime); - - // 画100个弧 - z = 0; - // 红色 - ctx.strokeStyle = "#FF0000"; - ctx.lineWidth = 1; - console.log("stroke 100 times contains 100 times arc begin =========" + myTime); - for(i = 0; i< 100; i++) { - z = z + 10; - ctx.beginPath(); - ctx.arc(170,z,5,Math.PI*2*(0/360),Math.PI*2*(140/360),false); - ctx.stroke(); - } - console.log("stroke 100 times contains 100 times arc end =========" + myTime); + performance001Func: function() { + drawLinesWithSingleStrokeAndOneSeparate.call(this); + drawRectanglesWithSingleStrokeAndOneSeparate.call(this); + drawArcsWithSingleStrokeAndOneSeparate.call(this); + drawLinesWithMultipleStrokes.call(this); + drawRectanglesWithMultipleStrokes.call(this); + drawArcsWithMultipleStrokes.call(this); }, performance002Func: function() { var myDate = new Date(); @@ -154,7 +53,6 @@ export default { ctx.stroke(); } console.log("stroke 10 time contains 10 times rect end =========" + myTime); - // 画10个弧 // 红色 ctx.strokeStyle = "#FF0000"; @@ -167,4 +65,130 @@ export default { } console.log("stroke 10 times contains 10 times arc end =========" + myTime); } +} + +function drawLinesWithSingleStrokeAndOneSeparate() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var x = 0; + + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 5; + ctx.beginPath(); + for (var i = 0; i < 100; i++) { + x += 10; + ctx.moveTo(10, x); + ctx.lineTo(30, x); + } + ctx.stroke(); + console.log("stroke 1 time contains 100 times moveTo+lineTo end =========" + myTime); + + ctx.beginPath(); + ctx.strokeStyle = "#0000FF"; + ctx.lineWidth = 3; + ctx.moveTo(10, x + 10); + ctx.lineTo(30, x + 10); + ctx.stroke(); +} + +function drawRectanglesWithSingleStrokeAndOneSeparate() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var y = 0; + + ctx.beginPath(); + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 2; + for (var i = 0; i < 100; i++) { + y += 10; + ctx.rect(40, y, 20, 4); + } + ctx.stroke(); + console.log("stroke 1 time contains 100 times rect end =========" + myTime); + + ctx.beginPath(); + ctx.strokeStyle = "#0000FF"; + ctx.lineWidth = 2; + ctx.rect(40, y + 10, 20, 4); + ctx.stroke(); +} + +function drawArcsWithSingleStrokeAndOneSeparate() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var z = 0; + + ctx.beginPath(); + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 2; + for (var i = 0; i < 100; i++) { + z += 10; + ctx.arc(80, z, 5, Math.PI * 2 * (0 / 360), Math.PI * 2 * (90 / 360), false); + } + ctx.stroke(); + console.log("stroke 1 time contains 100 times arc end =========" + myTime); + + ctx.beginPath(); + ctx.strokeStyle = "#0000FF"; + ctx.lineWidth = 2; + ctx.arc(80, z + 10, 5, Math.PI * 2 * (0 / 360), Math.PI * 2 * (90 / 360), false); + ctx.stroke(); +} + +function drawLinesWithMultipleStrokes() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var x = 0; + + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 1; + console.log("stroke 100 times contains 100 times moveTo+lineTo begin =========" + myTime); + for (var i = 0; i < 100; i++) { + x += 10; + ctx.beginPath(); + ctx.moveTo(100, x); + ctx.lineTo(130, x); + ctx.stroke(); + } + console.log("stroke 100 times contains 100 times moveTo+lineTo end =========" + myTime); +} + +function drawRectanglesWithMultipleStrokes() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var y = 0; + + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 1; + console.log("stroke 100 times contains 100 times rect begin =========" + myTime); + for (var i = 0; i < 100; i++) { + y += 10; + ctx.beginPath(); + ctx.rect(140, y, 20, 4); + ctx.stroke(); + } + console.log("stroke 100 times contains 100 times rect end =========" + myTime); +} + +function drawArcsWithMultipleStrokes() { + var canvasRef = this.$refs.canvas1; + var ctx = canvasRef.getContext("2d"); + var myTime = new Date().toLocaleTimeString(); + var z = 0; + + ctx.strokeStyle = "#FF0000"; + ctx.lineWidth = 1; + console.log("stroke 100 times contains 100 times arc begin =========" + myTime); + for (var i = 0; i < 100; i++) { + z += 10; + ctx.beginPath(); + ctx.arc(170, z, 5, Math.PI * 2 * (0 / 360), Math.PI * 2 * (140 / 360), false); + ctx.stroke(); + } + console.log("stroke 100 times contains 100 times arc end =========" + myTime); } \ No newline at end of file -- Gitee