try(getURL(...))
to read each element of urls
. After
each try, write a row to file.
indicating which of urls
was tested, the test time in seconds, and any error message. Repeat
any failures up to maxFail
times. After testing each element
of urls
once, repeat n
times.
If(ping), preceed each test with "ping url[i]". NOTE: Some Internet
Service Providers seem to block some attepts to use "ping" or return
fraudulet replies to "ping". It is included in the code, because it
seemed like an obvious test. However, it is not executed by default
because the results do not necessarily reflect what people might
expect from "ping".
Return a list of the last successful version read if any from each
element of urls
with two attributes: (1) "urls" containing the
urls
argument. (2) "testResults" being an object of class
c('testURLs', 'data.frame')
of the test results written to
file.
.
This function was written to diagnose a download problem with a
particular Internet Service Provider (ISP). For other tools for
testing an ISP, see
testURLs(urls=c(
wiki="http://en.wikipedia.org",
wiki.PVI="http://en.wikipedia.org/wiki/Cook_Partisan_Voting_Index",
house="http://house.gov",
house.reps="http://house.gov/representatives"),
file.='testURLresults.csv',
n=10, maxFail=10, warn=-1, tzone='GMT', ping=FALSE, ...)
getURL
for testing.
The default was selected to provide a 2 x 2 experiment with two
different web sites (en.wikipurls
.warn
argument to pass to Ping
.Time
. Defaults to GMT (UTC). tzone=NULL will
use the current locale.Ping
, FALSE otherwise.Ping
.testURLs
, which in this case is a list of
the last successful result returned by getURL
for
each element of urls
with the following attributes:urls
argument used for this callc('testURLs', 'data.frame')
of the
data written to file.
. This has the following columns:
date()
for the time a particular test started
}
urls
of the URL tested}
count
and stats
returned
by Ping
.
}
getURL
is computed
by computing start.time <- proc.time()
before calling
try(getURL(.))
, then computing the following after:
elapsed.time <- max(proc.time() - start.time, na.rm=TRUE)
After each of the urls
is tested, a summary of the results is
appended to file.
. This includes the pingi[['stats']],
elapsed.time
and the error message if the download failed.
The Electronic Frontier Foundation provides a table of existing
software to "Test your ISP"; see the references below. This table
includes a column noting whether the software is "active" (sending
test traffic) or "passive" (observing the way the network treats
natural traffic). The current testURLs
function is "active",
because it asks for a copy of the code at the indicated URL.try
getURL
Ping
# Test only 2 web sites, not the default 4,
# and test only twice, not the default 10 times:
tst <- testURLs(c(
PVI="http://en.wikipedia.org/wiki/Cook_Partisan_Voting_Index",
house="http://house.gov/representatives"),
n=2, maxFail=2)
stopifnot(
(class(tst) == 'testURLs') &&
all(names(tst) == c('PVI', 'house')) &&
all(names(attributes(tst)) ==
c('names', 'urls', 'testURLresults', 'class'))
)
Run the code above in your browser using DataLab