Skip to content

Commit

Permalink
add test coverage checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tarakc02 committed Dec 19, 2016
1 parent 675b343 commit dad87ed
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 8 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
^README-.*\.png$
^cran-comments\.md$
^\.travis\.yml$
^codecov\.yml$
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
language: R
sudo: false
cache: packages

after_success:
- Rscript -e 'covr::codecov()'
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ RoxygenNote: 5.0.1
Suggests: testthat,
microbenchmark,
knitr,
rmarkdown
rmarkdown,
covr
Imports: assertthat
VignetteBuilder: knitr
1 change: 1 addition & 0 deletions README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ output:
<!-- README.md is generated from README.Rmd. Please edit that file -->

[![Travis-CI Build Status](https://travis-ci.org/tarakc02/ratelimitr.svg?branch=master)](https://travis-ci.org/tarakc02/ratelimitr)
[![Coverage Status](https://img.shields.io/codecov/c/github/tarakc02/ratelimitr/master.svg)](https://codecov.io/github/tarakc02/ratelimitr?branch=master)

```{r, echo = FALSE}
knitr::opts_chunk$set(
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ ratelimitr
================

<!-- README.md is generated from README.Rmd. Please edit that file -->
[![Travis-CI Build Status](https://travis-ci.org/tarakc02/ratelimitr.svg?branch=master)](https://travis-ci.org/tarakc02/ratelimitr)
[![Travis-CI Build Status](https://travis-ci.org/tarakc02/ratelimitr.svg?branch=master)](https://travis-ci.org/tarakc02/ratelimitr) [![Coverage Status](https://img.shields.io/codecov/c/github/tarakc02/ratelimitr/master.svg)](https://codecov.io/github/tarakc02/ratelimitr?branch=master)

Introduction
------------
Expand All @@ -24,7 +24,7 @@ system.time(replicate(11, f()))
# time with limiting
system.time(replicate(11, f_lim()))
#> user system elapsed
#> 0.002 0.004 1.024
#> 0.007 0.000 1.025
```

Multiple rates
Expand All @@ -50,17 +50,17 @@ Sys.sleep(1)
# 11 function calls do trigger the rate limit
system.time(replicate(11, f_lim())); Sys.sleep(1)
#> user system elapsed
#> 0.011 0.000 0.128
#> 0.009 0.004 0.130

# similarly, 50 calls don't trigger the second rate limit
system.time(replicate(50, f_lim())); Sys.sleep(1)
#> user system elapsed
#> 0.052 0.004 0.525
#> 0.060 0.000 0.527

# but 51 calls do:
system.time(replicate(51, f_lim())); Sys.sleep(1)
#> user system elapsed
#> 0.086 0.000 1.025
#> 0.082 0.007 1.025
```

Multiple functions sharing one (or more) rate limit(s)
Expand Down Expand Up @@ -91,7 +91,7 @@ system.time(
{limited$f(); limited$g(); limited$h()}
)
#> user system elapsed
#> 0.001 0.000 0.001
#> 0.001 0.000 0.000

# sleep in between tests to reset the rate limit timer
Sys.sleep(1)
Expand All @@ -101,7 +101,7 @@ system.time(
{limited$f(); limited$g(); limited$h(); limited$f()}
)
#> user system elapsed
#> 0.010 0.000 1.027
#> 0.009 0.000 1.026
```

Limitations
Expand Down
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
comment: false

0 comments on commit dad87ed

Please sign in to comment.