Skip to content

Instantly share code, notes, and snippets.

@kvnkuang
kvnkuang / benchmarkPerformance.R
Created November 19, 2016 20:08
Benchmark the performance of pbapply and pbmcapply.
library(data.table)
library(pbapply)
library(pbmcapply)
timeConsumedPbapply <- data.table()
timeConsumedPbmcapply <- data.table()
timeConsumedapply <- data.table()
numCores <- 4L
repeats <- 50
maxNum <- 10
@kvnkuang
kvnkuang / benchmarkChildProcess.R
Created November 19, 2016 15:52
R code used for the benchmark of child processes created by pbapply/pbmcapply.
library(data.table)
library(pbapply)
library(pbmcapply)
# A lazy sqrt function which doesn't care about efficiency.
# It is derived from the testcases of pbmcapply package.
# It allows the program to run for a prolonged process so that
# we can monitor the forking process.
lazySqrt <- function(num) {
# Sleep randomly between 0 to 1 second