From 2076f41c01b5018b5a18a467b4bba92c855a9ff5 Mon Sep 17 00:00:00 2001 From: Postbot Date: Mon, 4 Sep 2017 17:44:14 +0800 Subject: [PATCH] Create _benchmarks/rgb-vs-rgb2.md --- _benchmarks/rgb-vs-rgb2.md | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 _benchmarks/rgb-vs-rgb2.md diff --git a/_benchmarks/rgb-vs-rgb2.md b/_benchmarks/rgb-vs-rgb2.md new file mode 100644 index 00000000..017df8d3 --- /dev/null +++ b/_benchmarks/rgb-vs-rgb2.md @@ -0,0 +1,41 @@ +--- +title: rgb vs rgb2 +setup: | + function rand(min,max) { + return min + Math.floor(Math.random() * ((max+1)-min) ); + } + + function randRGB2() { + return "rgb("+rand(0,255)+", "+rand(0,255)+", "+rand(0,255)+ ")"; + } + + function randRGB() { + var a = []; + for (var i = 0; i < 3; i++) { + a.push(rand(0,255)); + } + return "rgb("+a.join(", ")+")"; + } +tests: + - + name: rgb + code: | + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + document.getElementsByTagName('h2')[0].style.color = randRGB2(); + - + name: rgb2 + code: | + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); + document.getElementsByTagName('h2')[0].style.color = randRGB(); +--- +