privateIP.test vs shExpMatch

JavaScript performance comparison

Test case created by enk

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var host = "www.cisco.com"

};
</script>

Test runner

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

Java applet disabled.

Testing in CCBot 2.0.0 / Other 0.0.0
Test Ops/sec
privateIP.test
function FindProxyForURL(url, host) 
{
	var privateIP = /^(0|10|127|192\.168|172\.1[6789]|172\.2[0-9]|172\.3[01]|169\.254|192\.88\.99)\.[0-9.]+$/;

var resolved_ip = dnsResolve(host);

	if (isPlainHostName(host) || privateIP.test(resolved_ip)) {
			return "DIRECT";
	}
}
pending…
privateIP.test without isPlainHostName
function FindProxyForURL(url, host) 
{
	var privateIP = /^(0|10|127|192\.168|172\.1[6789]|172\.2[0-9]|172\.3[01]|169\.254|192\.88\.99)\.[0-9.]+$/;

var resolved_ip = dnsResolve(host);

	if (privateIP.test(resolved_ip)) {
			return "DIRECT";
	}
}
pending…
stupid comparasion
function FindProxyForURL(url, host) 
{

var resolved_ip = dnsResolve(host);

if (shExpMatch(resolved_ip, "127.*.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "192.168.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "0.*.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "10.*.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.16.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.17.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.18.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.19.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.20.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.21.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.22.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.23.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.24.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.25.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.26.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.27.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.28.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.29.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.30.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "172.21.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "169.254.*.*")) return "DIRECT";
else if (shExpMatch(resolved_ip, "192.88.99.*")) return "DIRECT";

}
pending…
stupid comparasion optimized
function FindProxyForURL(url, host) 
{

var resolved_ip = dnsResolve(host);

if ((shExpMatch(resolved_ip, "127.*.*.*")) || 
(shExpMatch(resolved_ip, "192.168.*")) || 
(shExpMatch(resolved_ip, "0.*.*.*")) || 
(shExpMatch(resolved_ip, "10.*.*.*")) || 
(shExpMatch(resolved_ip, "172.16.*.*")) || 
(shExpMatch(resolved_ip, "172.17.*.*")) || 
(shExpMatch(resolved_ip, "172.18.*.*")) || 
(shExpMatch(resolved_ip, "172.19.*.*")) || 
(shExpMatch(resolved_ip, "172.20.*.*")) || 
(shExpMatch(resolved_ip, "172.21.*.*")) || 
(shExpMatch(resolved_ip, "172.22.*.*")) || 
(shExpMatch(resolved_ip, "172.23.*.*")) || 
(shExpMatch(resolved_ip, "172.24.*.*")) || 
(shExpMatch(resolved_ip, "172.25.*.*")) || 
(shExpMatch(resolved_ip, "172.26.*.*")) || 
(shExpMatch(resolved_ip, "172.27.*.*")) || 
(shExpMatch(resolved_ip, "172.28.*.*")) || 
(shExpMatch(resolved_ip, "172.29.*.*")) || 
(shExpMatch(resolved_ip, "172.30.*.*")) || 
(shExpMatch(resolved_ip, "172.21.*.*")) || 
(shExpMatch(resolved_ip, "169.254.*.*")) || 
(shExpMatch(resolved_ip, "192.88.99.*"))) return "DIRECT";

}
pending…
isinnet
function FindProxyForURL(url, host) 
{

var resolved_ip = dnsResolve(host);

if ((isInNet(resolved_ip , "192.168.0.0", "255.255.0.0")) || (isInNet(resolved_ip , "172.16.0.0", "255.240.0.0")) || (isInNet(resolved_ip , "10.0.0.0", "255.0.0.0")) || (isInNet(resolved_ip , "127.0.0.0", "255.0.0.0")) || (isInNet(resolved_ip , "0.0.0.0", "255.0.0.0")) || (isInNet(resolved_ip , "169.254.0.0", "255.255.0.0")) || (isInNet(resolved_ip , "192.88.99.0", "255.255.255.0"))) return "DIRECT";

}
pending…

Revisions

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

0 Comments