mirror of
https://github.com/danog/dns.git
synced 2025-01-22 21:41:11 +01:00
Add simple examples that queries 10 out of the top 500 domains
This commit is contained in:
parent
ad55bcf870
commit
5f73365b9b
23
examples/benchmark.php
Normal file
23
examples/benchmark.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
|
||||
require __DIR__ . "/../vendor/autoload.php";
|
||||
|
||||
use Amp\Dns;
|
||||
use Amp\Loop;
|
||||
|
||||
$domains = file_get_contents("https://moz.com/top500/domains/csv");
|
||||
$domains = array_map(function ($line) {
|
||||
return trim(explode(",", $line)[1], '"/');
|
||||
}, array_filter(explode("\n", $domains)));
|
||||
|
||||
Loop::run(function () use ($domains) {
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$domain = $domains[mt_rand(0, count($domains) - 1)];
|
||||
|
||||
try {
|
||||
yield Dns\resolve($domain);
|
||||
} catch (Dns\ResolutionException $e) {
|
||||
print $domain . ": " . get_class($e) . PHP_EOL;
|
||||
}
|
||||
}
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user