[ES6] Add several generator related JSRegress tests to measure performance change...
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Dec 2015 16:38:04 +0000 (16:38 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 10 Dec 2015 16:38:04 +0000 (16:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=151785

Reviewed by Saam Barati.

Before starting optimization for ES6 Generators, add several JSRegress tests to measure that.

* js/regress/generator-create-expected.txt: Added.
* js/regress/generator-create.html: Added.
* js/regress/generator-fib-expected.txt: Added.
* js/regress/generator-fib.html: Added.
* js/regress/generator-function-create-expected.txt: Added.
* js/regress/generator-function-create.html: Added.
* js/regress/generator-sunspider-access-nsieve-expected.txt: Added.
* js/regress/generator-sunspider-access-nsieve.html: Added.
* js/regress/generator-with-several-types-expected.txt: Added.
* js/regress/generator-with-several-types.html: Added.
* js/regress/script-tests/generator-create.js: Added.
(gen):
* js/regress/script-tests/generator-fib.js: Added.
(result):
* js/regress/script-tests/generator-function-create.js: Added.
(createGeneratorFunction.gen):
(createGeneratorFunction):
* js/regress/script-tests/generator-sunspider-access-nsieve.js: Added.
(prime):
(sieve):
* js/regress/script-tests/generator-with-several-types.js: Added.
(g1):
(g2):
(g3):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@193907 268f45cc-cd09-0410-ab3c-d52691b4dbfc

16 files changed:
LayoutTests/ChangeLog
LayoutTests/js/regress/generator-create-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/generator-create.html [new file with mode: 0644]
LayoutTests/js/regress/generator-fib-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/generator-fib.html [new file with mode: 0644]
LayoutTests/js/regress/generator-function-create-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/generator-function-create.html [new file with mode: 0644]
LayoutTests/js/regress/generator-sunspider-access-nsieve-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/generator-sunspider-access-nsieve.html [new file with mode: 0644]
LayoutTests/js/regress/generator-with-several-types-expected.txt [new file with mode: 0644]
LayoutTests/js/regress/generator-with-several-types.html [new file with mode: 0644]
LayoutTests/js/regress/script-tests/generator-create.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/generator-fib.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/generator-function-create.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/generator-sunspider-access-nsieve.js [new file with mode: 0644]
LayoutTests/js/regress/script-tests/generator-with-several-types.js [new file with mode: 0644]

index adfedc5..ed2ea29 100644 (file)
@@ -1,3 +1,37 @@
+2015-12-10  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [ES6] Add several generator related JSRegress tests to measure performance change after optimization
+        https://bugs.webkit.org/show_bug.cgi?id=151785
+
+        Reviewed by Saam Barati.
+
+        Before starting optimization for ES6 Generators, add several JSRegress tests to measure that.
+
+        * js/regress/generator-create-expected.txt: Added.
+        * js/regress/generator-create.html: Added.
+        * js/regress/generator-fib-expected.txt: Added.
+        * js/regress/generator-fib.html: Added.
+        * js/regress/generator-function-create-expected.txt: Added.
+        * js/regress/generator-function-create.html: Added.
+        * js/regress/generator-sunspider-access-nsieve-expected.txt: Added.
+        * js/regress/generator-sunspider-access-nsieve.html: Added.
+        * js/regress/generator-with-several-types-expected.txt: Added.
+        * js/regress/generator-with-several-types.html: Added.
+        * js/regress/script-tests/generator-create.js: Added.
+        (gen):
+        * js/regress/script-tests/generator-fib.js: Added.
+        (result):
+        * js/regress/script-tests/generator-function-create.js: Added.
+        (createGeneratorFunction.gen):
+        (createGeneratorFunction):
+        * js/regress/script-tests/generator-sunspider-access-nsieve.js: Added.
+        (prime):
+        (sieve):
+        * js/regress/script-tests/generator-with-several-types.js: Added.
+        (g1):
+        (g2):
+        (g3):
+
 2015-12-10  Carlos Garcia Campos  <cgarcia@igalia.com>
 
         Unreviewed. Fix ambiguous expectations added in r193895.
diff --git a/LayoutTests/js/regress/generator-create-expected.txt b/LayoutTests/js/regress/generator-create-expected.txt
new file mode 100644 (file)
index 0000000..e1d51fe
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/generator-create
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/generator-create.html b/LayoutTests/js/regress/generator-create.html
new file mode 100644 (file)
index 0000000..6197986
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/generator-create.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/generator-fib-expected.txt b/LayoutTests/js/regress/generator-fib-expected.txt
new file mode 100644 (file)
index 0000000..468e11b
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/generator-fib
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/generator-fib.html b/LayoutTests/js/regress/generator-fib.html
new file mode 100644 (file)
index 0000000..b95266d
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/generator-fib.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/generator-function-create-expected.txt b/LayoutTests/js/regress/generator-function-create-expected.txt
new file mode 100644 (file)
index 0000000..f68ec07
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/generator-function-create
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/generator-function-create.html b/LayoutTests/js/regress/generator-function-create.html
new file mode 100644 (file)
index 0000000..74dadfd
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/generator-function-create.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/generator-sunspider-access-nsieve-expected.txt b/LayoutTests/js/regress/generator-sunspider-access-nsieve-expected.txt
new file mode 100644 (file)
index 0000000..db4d04e
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/generator-sunspider-access-nsieve
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/generator-sunspider-access-nsieve.html b/LayoutTests/js/regress/generator-sunspider-access-nsieve.html
new file mode 100644 (file)
index 0000000..e772941
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/generator-sunspider-access-nsieve.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/generator-with-several-types-expected.txt b/LayoutTests/js/regress/generator-with-several-types-expected.txt
new file mode 100644 (file)
index 0000000..fa2f633
--- /dev/null
@@ -0,0 +1,10 @@
+JSRegress/generator-with-several-types
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS no exception thrown
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/js/regress/generator-with-several-types.html b/LayoutTests/js/regress/generator-with-several-types.html
new file mode 100644 (file)
index 0000000..61aa92a
--- /dev/null
@@ -0,0 +1,12 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<script src="../../resources/js-test-pre.js"></script>
+</head>
+<body>
+<script src="../../resources/regress-pre.js"></script>
+<script src="script-tests/generator-with-several-types.js"></script>
+<script src="../../resources/regress-post.js"></script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/js/regress/script-tests/generator-create.js b/LayoutTests/js/regress/script-tests/generator-create.js
new file mode 100644 (file)
index 0000000..4c72102
--- /dev/null
@@ -0,0 +1,9 @@
+function *gen()
+{
+    yield 42;
+    yield 400;
+}
+noInline(gen);
+
+for (var i = 0; i < 1e4; ++i)
+    gen();
diff --git a/LayoutTests/js/regress/script-tests/generator-fib.js b/LayoutTests/js/regress/script-tests/generator-fib.js
new file mode 100644 (file)
index 0000000..cd971e0
--- /dev/null
@@ -0,0 +1,22 @@
+var result = (function () {
+    function *fib()
+    {
+        let a = 1;
+        let b = 1;
+        while (true) {
+            yield a;
+            [a, b] = [b, a + b];
+        }
+    }
+
+    let value = 0;
+    for (let i = 0; i < 1e4; ++i) {
+        let f = fib();
+        for (let i = 0; i < 100; ++i) {
+            value = f.next().value;
+        }
+    }
+    return value;
+}());
+if (result !== 354224848179262000000)
+    throw new Error(`bad value:${result}`);
diff --git a/LayoutTests/js/regress/script-tests/generator-function-create.js b/LayoutTests/js/regress/script-tests/generator-function-create.js
new file mode 100644 (file)
index 0000000..d10c137
--- /dev/null
@@ -0,0 +1,12 @@
+function createGeneratorFunction()
+{
+    function *gen()
+    {
+        yield 20;
+        yield 30;
+    }
+    return gen;
+}
+noInline(createGeneratorFunction);
+for (var i = 0; i < 1e4; ++i)
+    createGeneratorFunction();
diff --git a/LayoutTests/js/regress/script-tests/generator-sunspider-access-nsieve.js b/LayoutTests/js/regress/script-tests/generator-sunspider-access-nsieve.js
new file mode 100644 (file)
index 0000000..8f44b3a
--- /dev/null
@@ -0,0 +1,37 @@
+// The Great Computer Language Shootout
+// http://shootout.alioth.debian.org/
+//
+// modified by Isaac Gouy
+
+function *prime(m)
+{
+   let isPrime = Array(m+1);
+
+   for (let i=2; i<=m; i++) { isPrime[i] = true; }
+
+   for (let i=2; i<=m; i++){
+      if (isPrime[i]) {
+         for (let k=i+i; k<=m; k+=i) isPrime[k] = false;
+         yield i;
+      }
+   }
+}
+
+function sieve() {
+    let sum = 0;
+    for (let i = 1; i <= 3; i++ ) {
+        let m = (1<<i)*10000;
+        let count = 0;
+        for (let primeNumber of prime(m)) {
+            count++;
+        }
+        sum += count;
+    }
+    return sum;
+}
+
+let result = sieve();
+
+let expected = 14302;
+if (result != expected)
+    throw "ERROR: bad result: expected " + expected + " but got " + result;
diff --git a/LayoutTests/js/regress/script-tests/generator-with-several-types.js b/LayoutTests/js/regress/script-tests/generator-with-several-types.js
new file mode 100644 (file)
index 0000000..314c2fe
--- /dev/null
@@ -0,0 +1,33 @@
+(function () {
+    function *g1() {
+        for (let i = 0; i < 100; ++i)
+            yield i;
+    }
+
+    function *g2() {
+        for (let i = 0; i < 100; ++i)
+            yield String.fromCharCode(i);
+    }
+
+    function *g3() {
+        for (let i = 0; i < 100; ++i)
+            yield {};
+    }
+
+    for (let i = 0; i < 1e4; ++i) {
+        {
+            let g = g1();
+            for (let element of g);
+        }
+
+        {
+            let g = g2();
+            for (let element of g);
+        }
+
+        {
+            let g = g3();
+            for (let element of g);
+        }
+    }
+}());