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

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

Issue 18687003: Import intl test suite from v8-i18n project (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years, 5 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
Index: test/intl/overrides/caching.js
diff --git a/test/mjsunit/regress/regress-crbug-178790.js b/test/intl/overrides/caching.js
similarity index 65%
copy from test/mjsunit/regress/regress-crbug-178790.js
copy to test/intl/overrides/caching.js
index 57071eaa087c3503c4d1ef56e0fd87000a364a29..b15d8d39de2ce30d22fe92f195fe64d21fc91ccc 100644
--- a/test/mjsunit/regress/regress-crbug-178790.js
+++ b/test/intl/overrides/caching.js
@@ -24,29 +24,38 @@
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+// limitations under the License.
-// 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);

Powered by Google App Engine
This is Rietveld 408576698