GithubHelp home page GithubHelp logo

devoid's Introduction

devoid

R build status

This package provides a graphic device that does no operations. This makes it suitable for benchmarking functions that produce graphics as it removes the device implementation from the equation. In contrast to the nulldev() function from R.devices package this device is a true device implementation that simply does nothing rather than calling pdf() with a temporary file connection.

Installation

You can install devoid with the remotes package:

# install.packages('remotes')
remotes::install_github('r-lib/devoid')

Example

devoid provides a single function void_dev() which is used much like any other device:

library(devoid)

void_dev()
plot(1:10, 1:10)
dev.off()
#> quartz_off_screen 
#>                 2

Using it we can now see how much drawing time e.g. the png device is responsible for:

point_coord <- seq_len(1e4)
void_plot <- function() {
  void_dev()
  plot(point_coord, point_coord)
  dev.off()
  NULL
}
png_plot <- function() {
  png(tempfile())
  plot(point_coord, point_coord)
  dev.off()
  NULL
}

res <- bench::mark(devoid = void_plot(), png = png_plot(), min_iterations = 50)
plot(res)
#> Loading required namespace: tidyr

devoid's People

Contributors

thomasp85 avatar pmur002 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.