Vector Search vs. Binary Search
This article is originally published at https://statcompute.wordpress.com
# REFERENCE: # user2014.stat.ucla.edu/files/tutorial_Matt.pdf pkgs <- c('data.table', 'rbenchmark') lapply(pkgs, require, character.only = T) load('2008.Rdata') dt <- data.table(data) benchmark(replications = 10, order = "elapsed", vector_search = { test1 <- dt[ArrTime == 1500 & Origin == 'ABE', ] }, binary_search = { setkey(dt, ArrTime, Origin) test2 <- dt[.(1500, 'ABE'), ] } ) # test replications elapsed relative user.self sys.self user.child # 2 binary_search 10 0.335 1.000 0.311 0.023 0 # 1 vector_search 10 7.245 21.627 7.102 0.131 0
Thanks for visiting r-craft.org
This article is originally published at https://statcompute.wordpress.com
Please visit source website for post related comments.