Skip to content

Commit

Permalink
the self-made dns benchmark program!
Browse files Browse the repository at this point in the history
  • Loading branch information
gugod committed Jan 7, 2010
1 parent db76022 commit e9f2ea2
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions dns-benchmark
@@ -0,0 +1,40 @@
#!/usr/bin/env perl
use common::sense;
use URI;
use Mac::PropertyList;
use Net::DNS;
use YAML qw(Dump);
use Time::HiRes qw(time);

local $/ = undef;
my @nameserver = split "\n", <DATA>;
say Dump({"Testing Servers" => \@nameserver});

my @urls;
my @hosts;
my $plist = Mac::PropertyList::parse_plist_file("$ENV{HOME}/Library/Safari/History.plist");

for($plist->value->{WebHistoryDates}->value) {
unshift @urls, $_->{''}->value;
}

my %time_for;

for my $ns (@nameserver) {
$time_for{$ns} = 0;
my $res = Net::DNS::Resolver->new(nameservers => [$ns]);
for (@urls) {
my $host = URI->new($_)->host;

my $t = time;
my $answer = $res->query($host);
$time_for{$ns} += time - $t;
}
}

say YAML::Dump(\%time_for);

__DATA__
8.8.8.8
168.95.1.1
168.95.192.1

0 comments on commit e9f2ea2

Please sign in to comment.