toLowerCase indexOf vs. RegExp test (v2)

Revision 2 of this benchmark created by Kacy on


Description

Test case to see how indexOf in conjunction with toLowerCase will perform against a Regular Expression test.

Preparation HTML

<textarea id="test">
<?xml version="1.0" ?> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" dir="ltr"><head><meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> 
<meta http-equiv="Cache-Control" content="no-cache" /> 
<meta name="HandheldFriendly" content="true" /> 
<link rel="alternate" media="handheld" href="" /> 
<style type="text/css"> 
    body {font-size:small;font-family:Arial, Helvetica, sans-serif;}
    h1 {font-size:large;color:#1d46a6;margin-bottom:0.4em;}
    p {margin-top:0.4em;margin-bottom:0.4em}
 
    .center {text-align:center;}
    .nobr {white-space: nowrap}
  </style> 
<style type="text/css"> 
        h2 {font-size:small;color:#316ba6;font-weight:bold;padding-top:10px;}
        .new {font-size:small;color:#ee0055;font-weight:bold;padding-top:10px;margin-bottom:0.8em;}
        .product-icon {vertical-align:bottom;}
        .promoheading {font-size:small;color:#316ba6;font-weight:bold;padding-top:10px;margin-bottom:0.8em;}
      </style> 
<title>Google Mobile</title></head> 
<body id="ProductsPage"><img src="http://ad.doubleclick.net/activity;src=2542116;type=mobil635;cat=mobil356;ord=326156444?" width="1" height="1" alt="" /> 
<div id="container"><p> 
Looking for Search? Visit <a href="http://www.google.com/m?source=backstop&amp;session=6973391152&amp;dc=gorganic">Google.com</a>.</p> 
<img src="http://www.gstatic.com/mgc/images/google_logo_small.gif" width="110" height="33" alt="Google Mobile" /> 
<h2>Google mobile products</h2> 
<img src="http://www.gstatic.com/mgc/images/icons/16x16/search.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="search" href="http://www.google.com/m?source=mobileproducts&amp;dc=gorganic">Search</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/gmail.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="pudu" href="http://m.google.com/mail?session=6973391152&amp;dc=gorganic">Gmail</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/maps.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="gmm_local" href="http://m.google.com/maps?session=6973391152&amp;dc=gorganic">Maps</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/buzz.png" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="buzz" href="https://m.google.com/app/buzz">Buzz</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/news.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="news" href="http://m.google.com/news?session=6973391152&amp;dc=gorganic">News</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/igoogle.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="igoogle" href="http://www.google.com/m/ig?source=products&amp;dc=gorganic">iGoogle</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/sync.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="sync_config" href="https://m.google.com/sync/settings/?source=mobileproducts">Sync</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/picasa.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="photos" href="http://m.google.com/photos?session=6973391152&amp;dc=gorganic">Photos</a> 
<br /> <img src="http://m.google.com/images/icons/16x16/voice.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="voice_webapp" href="http://www.google.com/voice/m?dc=gorganic">Voice</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/calendar.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="calendar" href="http://m.google.com/calendar?session=6973391152&amp;dc=gorganic">Calendar</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/reader.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="reader" href="http://m.google.com/reader?session=6973391152&amp;dc=gorganic">Reader</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/sms.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="sms" href="http://m.google.com/sms?session=6973391152&amp;dc=gorganic">SMS</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/orkut.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="orkut" href="http://m.google.com/orkut?session=6973391152&amp;dc=gorganic">Orkut</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/docs.png" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="docs" href="http://m.google.com/docs?session=6973391152&amp;dc=gorganic">Docs</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/notebook.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="notebook" href="http://m.google.com/notebook?session=6973391152&amp;dc=gorganic">Notebook</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/blogger.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="blogger" href="http://m.google.com/blogger?session=6973391152&amp;dc=gorganic">Blogger</a> 
<br /> <img src="http://www.gstatic.com/mgc/images/icons/16x16/tasks.gif" width="16" height="16" alt="" />&nbsp;<a class="productLink productName" id="tasks" href="http://m.google.com/tasks?session=6973391152&amp;dc=gorganic">Tasks</a> 
<br /> 
<br /> 
*Tip: Bookmark this page for quick access to Google services.
<br /> 
<a id="changeCountry" href="http://m.google.com/countries/?session=6973391152&amp;dc=gorganic">Not in United States?</a> 
<br /> 
<br /> 
<a id="help" href="http://m.google.com/m/help/?session=6973391152&amp;dc=gorganic">Help</a> 
<br /> 
<div><div style="padding-top:0.5em"><img src="http://www.gstatic.com/mgc/images/icons/change_language.gif" width="32" height="16" style="vertical-align:top;" alt="" /><a id="changeLanguage" href="http://m.google.com/languages/?session=6973391152&amp;dc=gorganic&amp;continue=http://m.google.com/?session%3D6973391152" style="vertical-align:top; margin-top:1em">Change Language</a></div><p style="text-align: center;">&copy;2011&nbsp;-&nbsp;<span class="nobr"><a href="http://m.google.com/m/terms?session=6973391152&amp;dc=gorganic">Terms of Service</a></span>&nbsp;-&nbsp;<span class="nobr"><a href="http://m.google.com/privacy?session=6973391152&amp;dc=gorganic">Privacy Policy</a></span></p></div></div></body></html>
</textarea>
<script>
  var obj = document.getElementById('test');
</script>

Test runner

Ready to run.

Testing in
TestOps/sec
toLowerCase indexOf
return (obj.value.toLowerCase().indexOf('<img') > -1);
ready
RegExp test
return /<img/i.test(obj.value);
ready

Revisions

You can edit these tests or add more tests to this page by appending /edit to the URL.