url_test

JavaScript performance comparison

Test case created

Test runner

Warning! For accurate results, please disable Firebug before running the tests. (Why?)

Java applet disabled.

Testing in unknown unknown
Test Ops/sec
tjb
var output = "";
function testUrl(str){
    var arr = [];
    var valid = true;
    str = str.split('?');    
    str = str[1].split('&');

    for(i=0; i<str.length; i++){
        var segment = str[i].split('=');
        if(segment[1] == ""){
            valid = false;
            break;
        }
        arr[i] = [];
        arr[i][0] = segment[0];
        arr[i][1] = segment[1];
    }

    if(valid) {
       for(var x in arr) {
            output += arr[x][0] +':'+ arr[x][1]+'\n';
       }
    } else {
        throw "The given URL is invalid";
    }
return output;
}
var urlStr = "http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page";
console.log(testUrl(urlStr));
pending…
bebe
var url1 = "http://en.wikipedia.org/w/index.php?title=Special:UserLogin&returnto=Main+Page";
function get_url(url,output,allowed,ch,i){
        output = "",
        allowed = ":!=?@[]_~#$%&'()*+,-./0abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        for (i = 0, len = url.length, qmark = url.indexOf('?'); i < len; i++){
                if (allowed.indexOf(url[i]) == -1) throw "The given URL is invalid";
                if (i > qmark){
                        if (url[i] == '&') output += '\"\n';
                        else if (url[i] == '=') output += ': \"';
                        else output += url[i];
                }
        }
        return output + '\"';
}
console.log(get_url(url1));
pending…

Compare results of other browsers

Revisions

You can edit these tests or add even more tests to this page by appending /edit to the URL. Here’s a list of current revisions for this page:

0 comments

Add a comment