Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@
^docs$
^pkgdown$
^.github$
^.vscode$
^air.toml$
^\.github$
75 changes: 0 additions & 75 deletions .github/workflows/check-standard.yaml

This file was deleted.

2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,5 @@ examples1.rds
doc
Meta
docs

/.quarto/
18 changes: 6 additions & 12 deletions .lintr
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
linters: with_defaults(
line_length_linter(100),
assignment_linter = NULL,
cyclocomp_linter(complexity_limit = 25), # default value
undesirable_operator_linter = undesirable_operator_linter(
with_defaults(
default_undesirable_operators,
"<-" = "Use =, not <-, for assignment."
)
)
)

linters: linters_with_defaults(
assignment_linter = NULL,
line_length_linter(100),
cyclocomp_linter(complexity_limit = 15),
undesirable_operator_linter = undesirable_operator_linter(
op = list("<-" = "Please use '=' for assignment")))
7 changes: 4 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Type: Package
Package: benchmarkme
Title: Crowd Sourced System Benchmarks
Version: 1.0.8
Version: 1.0.9
Authors@R:
person("Colin", "Gillespie", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0003-1787-0275"))
Expand All @@ -10,7 +10,8 @@ Description: Benchmark your CPU and compare against other CPUs. Also
provides functions for obtaining system specifications, such as RAM,
CPU type, and R version.
License: GPL-2 | GPL-3
URL: https://github.com/csgillespie/benchmarkme, https://csgillespie.github.io/benchmarkme/
URL: https://github.com/csgillespie/benchmarkme,
https://csgillespie.github.io/benchmarkme/
BugReports: https://github.com/csgillespie/benchmarkme/issues
Depends:
R (>= 3.5.0)
Expand Down Expand Up @@ -40,4 +41,4 @@ VignetteBuilder:
knitr
Encoding: UTF-8
LazyData: TRUE
RoxygenNote: 7.1.2
RoxygenNote: 7.3.2
21 changes: 13 additions & 8 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
# benchmarkme Version 1.0.9 _2024-05-06_
* fix: #49 thanks to @ptompalski
* feat: Add website to description #5o. Thanks to @olivroy
* chore: Use `air` for formatting

# benchmarkme Version 1.0.8 _2022-06-02_
* fix: `get_ram()` for windows (thanks to @ArkaB-DS @xiaodaigh #45)
* internal: linting & format NEWS.md file

# benchmarkme Version 1.0.7 _2022-01-17_
* Internal: Suppress warnings on `sysctl` calls
* Fix: `get_ram()` for windows (thanks to @ArkaB-DS #41)
Expand All @@ -28,7 +33,7 @@
# benchmarkme Version 1.0.0
* Update version focused on R 3.5 & above. Start anew. Sorry everyone

# benchmarkme Version 0.6.1
# benchmarkme Version 0.6.1
* Improved BLAS detection (suggested by @ck37 #15)

# benchmarkme Version 0.6.0
Expand All @@ -40,10 +45,10 @@
* Can now run `benchmark_std()` if the package is not attached (thanks to @YvesCR)
* Nicer version of `print.bytes()` (thanks to @richierocks)
* Adding parallel benchmarks (thanks to @jknowles)

# benchmarkme Version 0.5.0
* Bug fix in get_byte_compiler when `cmpfun` was used.

# benchmarkme Version 0.4.0
* Update to shinyapps.io example
* Moved benchmark description to shinyapps.io
Expand All @@ -54,13 +59,13 @@
* Used `Sys.getpid()` to try and determine the BLAS/LAPACK library (suggested by
Ashley Ford).

# benchmarkme Version 0.2.3
# benchmarkme Version 0.2.3
* Return `NA` for `get_cpu()`/`get_ram()` when it isn't possible to determine
CPU/RAM.

# benchmarkme Version 0.2.2
* First CRAN version

# benchmarkme Version 0.2.0
* More flexibility in plot and datatable functions - you can now specify the test you want to compare.
* The number of cores returned by `get_cpu()`.
Expand All @@ -84,7 +89,7 @@
* Further RAM and Mac issues.

# benchmarkme Version 0.1.4
* Bug fix: Remove white space from apple RAM output (thanks to @vzemlys). Fixes #2.
* Bug fix: Remove white space from apple RAM output (thanks to @vzemlys). Fixes #2.

# benchmarkme Version 0.1.3
* Add a fall-back when getting RAM - grab everything.
Expand Down
133 changes: 94 additions & 39 deletions R/benchmark_io.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
#' @importFrom utils read.csv write.csv
#' @rdname benchmark_io
#' @export
benchmark_io = function(runs = 3,
size = c(5, 50),
tmpdir = tempdir(),
verbose = TRUE,
cores = 0L) {
benchmark_io = function(
runs = 3,
size = c(5, 50),
tmpdir = tempdir(),
verbose = TRUE,
cores = 0L
) {
# Order size largest to smallest for trial run.
# Trial on largest

Expand All @@ -24,13 +26,20 @@ benchmark_io = function(runs = 3,
}
size = sort(size, decreasing = TRUE)
if (cores > 0) {
results = benchmark_io_parallel(runs = runs, size = size,
tmpdir = tmpdir, verbose = verbose,
cores = cores)
results = benchmark_io_parallel(
runs = runs,
size = size,
tmpdir = tmpdir,
verbose = verbose,
cores = cores
)
} else {
results = benchmark_io_serial(runs = runs, size = size,
tmpdir = tmpdir, verbose = verbose)

results = benchmark_io_serial(
runs = runs,
size = size,
tmpdir = tmpdir,
verbose = verbose
)
}
class(results) = c("ben_results", class(results))
results
Expand All @@ -56,37 +65,67 @@ benchmark_io_serial = function(runs, size, tmpdir, verbose) {

benchmark_io_parallel = function(runs, size, tmpdir, verbose, cores) {
message("Preparing read/write io")
bm_parallel("bm_write", runs = 1,
size = size[1], tmpdir = tmpdir,
verbose = verbose, cores = max(cores))
bm_parallel(
"bm_write",
runs = 1,
size = size[1],
tmpdir = tmpdir,
verbose = verbose,
cores = max(cores)
)
results = NULL
for (s in size) {
if (verbose) message("# IO benchmarks (2 tests) for size ", s, " MB (parallel)")
results = rbind(results,
bm_parallel("bm_write", runs = runs, size = s, tmpdir = tmpdir,
verbose = verbose, cores = cores))
results = rbind(results,
bm_parallel("bm_read", runs = runs, size = s, tmpdir = tmpdir,
verbose = verbose, cores = cores))
if (verbose)
message("# IO benchmarks (2 tests) for size ", s, " MB (parallel)")
results = rbind(
results,
bm_parallel(
"bm_write",
runs = runs,
size = s,
tmpdir = tmpdir,
verbose = verbose,
cores = cores
)
)
results = rbind(
results,
bm_parallel(
"bm_read",
runs = runs,
size = s,
tmpdir = tmpdir,
verbose = verbose,
cores = cores
)
)
}

results
}

#' @rdname benchmark_io
#' @export
bm_read = function(runs = 3, size = c(5, 50),
tmpdir = tempdir(), verbose = TRUE) {
bm_read = function(
runs = 3,
size = c(5, 50),
tmpdir = tempdir(),
verbose = TRUE
) {
n = 12.5e4 * size
set.seed(1)
on.exit(set.seed(NULL))
x = Rnorm(n)
m = data.frame(matrix(x, ncol = 10))
test = rep(paste0("read", size), runs)
timings = data.frame(user = numeric(runs), system = 0,
elapsed = 0, test = test,
test_group = test,
stringsAsFactors = FALSE)
test = rep(paste0("read", size), runs)
timings = data.frame(
user = numeric(runs),
system = 0,
elapsed = 0,
test = test,
test_group = test,
stringsAsFactors = FALSE
)
fname = tempfile(fileext = ".csv", tmpdir = tmpdir)
write.csv(m, fname, row.names = FALSE)
for (i in 1:runs) {
Expand All @@ -95,8 +134,12 @@ bm_read = function(runs = 3, size = c(5, 50),
read.csv(fname, colClasses = rep("numeric", 10))
})[1:3]
if (verbose) {
message(c("\t Reading a csv with ", n, " values",
timings_mean(timings[timings$test_group == paste0("read", size), ])))
message(c(
"\t Reading a csv with ",
n,
" values",
timings_mean(timings[timings$test_group == paste0("read", size), ])
))
}
}
unlink(fname)
Expand All @@ -106,18 +149,26 @@ bm_read = function(runs = 3, size = c(5, 50),

#' @rdname benchmark_io
#' @export
bm_write = function(runs = 3, size = c(5, 50),
tmpdir = tempdir(), verbose = TRUE) {
bm_write = function(
runs = 3,
size = c(5, 50),
tmpdir = tempdir(),
verbose = TRUE
) {
n = 12.5e4 * size
set.seed(1)
on.exit(set.seed(NULL))
x = Rnorm(n)
m = data.frame(matrix(x, ncol = 10))
test = rep(paste0("write", size), runs)
timings = data.frame(user = numeric(runs), system = 0,
elapsed = 0, test = test,
test_group = test,
stringsAsFactors = FALSE)
test = rep(paste0("write", size), runs)
timings = data.frame(
user = numeric(runs),
system = 0,
elapsed = 0,
test = test,
test_group = test,
stringsAsFactors = FALSE
)
for (i in 1:runs) {
fname = tempfile(fileext = ".csv", tmpdir = tmpdir)
invisible(gc())
Expand All @@ -127,8 +178,12 @@ bm_write = function(runs = 3, size = c(5, 50),
unlink(fname)
invisible(gc())
if (verbose) {
message(c("\t Writing a csv with ", n, " values",
timings_mean(timings[timings$test_group == paste0("write", size), ])))
message(c(
"\t Writing a csv with ",
n,
" values",
timings_mean(timings[timings$test_group == paste0("write", size), ])
))
}
}
timings
Expand Down
Loading