urn substr() (v18)

Revision 18 of this benchmark created on


Setup

var str = "urn:newsml:reuters.com:20131217:nDJXQ01C87:2";
    var regEx = /\.$/;
    var newsWiresUrnPrefix = "urn:newsml:reuters.com:"
    var obj = {'20131217:nDJXQ01C87:2': "" }

Test runner

Ready to run.

Testing in
TestOps/sec
substr
var id = "";
                // NewsRoom news object
                if (str.indexOf(newsWiresUrnPrefix) == -1) {
                        id = str;
                }
                else {
                    id = str.substr(newsWiresUrnPrefix.length, str.length - 1);
                }
                
                if (obj.hasOwnProperty(id)) {
                var i = 0;
                }
        
ready
empty
var id = "20131217:nDJXQ01C87:2";
if (obj.hasOwnProperty(id)) {
                var i = 0;
                }
 
ready

Revisions

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