time_start = proc.time()
nIter = 100
for (i in 1:nIter) {
Sys.sleep(i ^ 1.02 / 10000)
reportTime(i, time_start, nIter,
jobs = (1:100) ^ 1.02, prefix = 'Chain 1: ')
}
if (FALSE) {
# Unknown number of iterations:
time_start = proc.time()
for (i in 1:20) {
Sys.sleep(i ^ 2 / 10000)
reportTime(i = i, time_start = time_start,
jobs = (1:20) ^ 2, reportEvery = 5)
}
# when analyzing a bunch of audio files, their size is a good estimate
# of how long each will take to process
time_start = proc.time()
filenames = list.files('~/Downloads/temp', pattern = "*.wav|.mp3",
full.names = TRUE)
filesizes = file.info(filenames)$size
for (i in seq_along(filenames)) {
# ...do what you have to do with each file...
reportTime(i = i, time_start = time_start, nIter = length(filenames),
jobs = filesizes)
}
}
Run the code above in your browser using DataLab