shExpMatch vs host == string vs dnsDomainIs

JavaScript performance comparison

Test case created by enk

Preparation code


      
      <script>
Benchmark.prototype.setup = function() {
  var host = "www.juniper.net"
  var url = "https://www.juniper.net/go/ccie"

};
</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
shExpMatch
function FindProxyForURL(url, host) {
  if (shExpMatch(host, 'www.cisco.com')) return 'DIRECT';
  if (shExpMatch(host, 'www.juniper.net')) return 'PROXY1';
  if (shExpMatch(host, 'www.huawei.com')) return 'PROXY2';
}
pending…
host
function FindProxyForURL(url, host) {
  if (host == 'www.cisco.com') return 'DIRECT';
  if (host == 'www.juniper.com') return 'PROXY1';
  if (host == 'www.huawei.com') return 'PROXY2';
}
pending…
dnsDomainIs
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host,"www.cisco.com")) return 'DIRECT';
  if (dnsDomainIs(host,"www.juniper.com")) return 'PROXY1';
  if (dnsDomainIs(host,"www.huawei.com")) return 'PROXY2';
}
pending…
host or
function FindProxyForURL(url, host) {
  if ((host == 'www.cisco.com') || (host == 'www.juniper.com') || (host == 'www.huawei.com')) return 'PROXY';
}
pending…
host.substring
function FindProxyForURL(url, host) {
   if (host.substring(0,13) == "www.cisco.com") return 'PDIRECT';
   if (host.substring(0,15) == "www.juniper.com") return 'PROXY1';
   if (host.substring(0,14) == "www.huawei.com") return 'PROXY2';
}
pending…
localHostOrDomainIs
function FindProxyForURL(url, host) {
  if (localHostOrDomainIs(host,"www.cisco.com")) return 'DIRECT';
  if (localHostOrDomainIs(host,"www.juniper.com")) return 'PROXY1';
  if (localHostOrDomainIs(host,"www.huawei.com")) return 'PROXY2';
}
pending…
host elseif
function FindProxyForURL(url, host) {
  if (dnsDomainIs(host,"www.cisco.com")) return 'DIRECT';
  else if (dnsDomainIs(host,"www.juniper.com")) return 'PROXY1';
  else if (dnsDomainIs(host,"www.huawei.com")) return 'PROXY2';
}
pending…

Revisions

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

0 Comments