MyNixOS website logo
Description

'Ping' 'URLs' to Time 'Requests'.

A suite of functions to ping 'URLs' and to time 'HTTP' 'requests'. Designed to work with 'httr'.

httping

Build Status rstudio mirror downloads cran version

httping is a tiny R package to Ping urls to time requests. It's a port of the Ruby gem httping.

Install

CRAN stable version

install.packages("httping")

Development version from Github

install.packages("devtools")
devtools::install_github("sckott/httping")
library("httping")

Pass any httr request to time

A GET request

GET("https://google.com") %>% time(count = 3)
#> 22.464 kb - https://www.google.com/ code:200 time(ms):204.716
#> 21.96 kb - https://www.google.com/ code:200 time(ms):134.303
#> 21.96 kb - https://www.google.com/ code:200 time(ms):118.564
#> <http time>
#>   Avg. min (ms):  118.564
#>   Avg. max (ms):  204.716
#>   Avg. mean (ms): 152.5277

A POST request

POST("https://mockbin.com/request", body = "A simple text string") %>% time(count = 3)
#> 10.976 kb - https://mockbin.com/request code:200 time(ms):344.269
#> 10.832 kb - https://mockbin.com/request code:200 time(ms):194.178
#> 10.832 kb - https://mockbin.com/request code:200 time(ms):110.234
#> <http time>
#>   Avg. min (ms):  110.234
#>   Avg. max (ms):  344.269
#>   Avg. mean (ms): 216.227

The return object is a list with slots for all the httr response objects, the times for each request, and the average times. The number of requests, and the delay between requests are included as attributes.

res <- GET("http://google.com") %>% time(count = 3)
#> 22.064 kb - http://www.google.com/ code:200 time(ms):87.641
#> 21.56 kb - http://www.google.com/ code:200 time(ms):77.876
#> 21.56 kb - http://www.google.com/ code:200 time(ms):69.833
attributes(res)
#> $names
#> [1] "times"    "averages" "request" 
#> 
#> $count
#> [1] 3
#> 
#> $delay
#> [1] 0.5
#> 
#> $class
#> [1] "http_time"

Or print a summary of a response, gives more detail

res %>% summary()
#> <http time, averages (min max mean)>
#>   Total (s):           69.833 87.641 78.45
#>   Tedirect (s):        19.933 31.125 23.906
#>   Namelookup time (s): 0.05 1.884 0.6616667
#>   Connect (s):         0.054 11.052 3.72
#>   Pretransfer (s):     0.14 11.174 3.826
#>   Starttransfer (s):   48.783 57.503 54.06467

Messages are printed using cat, so you can suppress those using verbose=FALSE, like

GET("https://google.com") %>% time(count = 3, verbose = FALSE)
#> <http time>
#>   Avg. min (ms):  113.94
#>   Avg. max (ms):  135.96
#>   Avg. mean (ms): 128.36

Ping an endpoint

This function is a bit different, accepts a url as first parameter, but can accept any args passed on to httr verb functions, like GET, POST, etc.

"https://google.com" %>% ping()
#> <http ping> 200
#>   Message: OK
#>   Description: Request fulfilled, document follows

Or pass in additional arguments to modify request

"https://google.com" %>% ping(config = verbose())
#> <http ping> 200
#>   Message: OK
#>   Description: Request fulfilled, document follows

Meta

  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
Metadata

Version

0.2.0

License

Unknown

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows