Skip to content

r-staceans/blazr

Repository files navigation

blazr

R-CMD-check Codecov test coverage Lifecycle: experimental

⚠️ This package is a work in progress and is not yet ready for use.

The goal of blazr is to provide R with a blazingly fast interface to multi-threading in Rust.

Installation

Install the development version of blazr from GitHub with:

# install.packages("pak")
pak::pak("r-staceans/blazr")

Example

Here’s a simple example, computing the sum of a vector of integers, using multiple threads:

library(blazr)

create_int_vector <- function(n) {
  set.seed(42)
  sample.int(100, n, replace = TRUE)
}

n <- 1e8

x <- create_int_vector(n)

blazr::sum_with_threads(
  x,
  n = 2L
)
#> [1] 754832969

Benchmarking

When running this sum against very large numbers, we can see the performance benefits of using multiple threads:

library(bench)
library(ggplot2)

results <- bench::press(
  size = c(1e7, 1e8, 1e9),
  {
    x = create_int_vector(n)
    bench::mark(
      single_thread = {
        blazr::sum_with_threads(
          x,
          n = 1L
        )
      },
      multi_thread = {
        blazr::sum_with_threads(
          x,
          n = 4L
        )
      }
    )
  })
#> Running with:
#>         size
#> 1   10000000
#> 2  100000000
#> 3 1000000000

ggplot2::autoplot(results)
#> Loading required namespace: tidyr

About

blazr: multi-threading for R, with Rust

Resources

License

Unknown, MIT licenses found

Licenses found

Unknown
LICENSE
MIT
LICENSE.md

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published