Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(379)

Unified Diff: test/intl/overrides/caching.js

Issue 148883002: Synchronize with r15594. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « test/intl/number-format/wellformed-unsupported-locale.js ('k') | test/intl/overrides/date.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/intl/overrides/caching.js
diff --git a/test/mjsunit/regress/regress-crbug-178790.js b/test/intl/overrides/caching.js
similarity index 66%
copy from test/mjsunit/regress/regress-crbug-178790.js
copy to test/intl/overrides/caching.js
index 57071eaa087c3503c4d1ef56e0fd87000a364a29..5ff3c390e79abfa32f485ac043b2878827e0abfc 100644
--- a/test/mjsunit/regress/regress-crbug-178790.js
+++ b/test/intl/overrides/caching.js
@@ -25,28 +25,36 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Create a regexp in the form of a?a?...a? so that fully
-// traversing the entire graph would be prohibitively expensive.
-// This should not cause time out.
-var r1 = "";
+// Performance test for overriden methods. Makes sure that default case
+// is faster (cached) than the general case.
+
+// Default, cached.
+var startTime = new Date();
for (var i = 0; i < 1000; i++) {
- r1 += "a?";
+ 'a'.localeCompare('c');
}
-"test".match(RegExp(r1));
+var endTime = new Date();
+var cachedTime = endTime.getTime() - startTime.getTime();
-var r2 = "";
-for (var i = 0; i < 100; i++) {
- r2 += "(a?|b?|c?|d?|e?|f?|g?)";
+// Not cached.
+startTime = new Date();
+for (var i = 0; i < 1000; i++) {
+ 'a'.localeCompare('c', 'sr');
}
-"test".match(RegExp(r2));
+endTime = new Date();
+var nonCachedTime = endTime.getTime() - startTime.getTime();
-// Create a regexp in the form of ((..(a)a..)a.
-// Compiling it causes EatsAtLeast to reach the maximum
-// recursion depth possible with a given budget.
-// This should not cause a stack overflow.
-var r3 = "a";
+// Using collator. Faster than default, but not by much.
+var collator = Intl.Collator();
+startTime = new Date();
for (var i = 0; i < 1000; i++) {
- r3 = "(" + r3 + ")a";
+ collator.compare('a', 'c');
}
-"test".match(RegExp(r3));
+endTime = new Date();
+collatorTime = endTime.getTime() - startTime.getTime();
+
+// Difference is within 20%.
+assertTrue(collatorTime < cachedTime);
+// Non-cached time is much slower, measured to 12.5 times.
+assertTrue(cachedTime < nonCachedTime);
« no previous file with comments | « test/intl/number-format/wellformed-unsupported-locale.js ('k') | test/intl/overrides/date.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698