Skip to content

Instantly share code, notes, and snippets.

@szilard
Created February 11, 2016 21:50
Show Gist options
  • Save szilard/24833422fc1ec8901a71 to your computer and use it in GitHub Desktop.
Save szilard/24833422fc1ec8901a71 to your computer and use it in GitHub Desktop.
data.table materialized join vs not
## count
benchmark(
nrow(d[dm, nomatch=0L, on="x"]),
d[dm, .N, nomatch=0L, on="x"],
replications = 5, columns = c("test", "replications", "elapsed", "relative"))
# test replications elapsed relative
#2 d[dm, .N, nomatch = 0, on = "x"] 5 28.535 1.000
#1 nrow(d[dm, nomatch = 0, on = "x"]) 5 38.562 1.351
## sum(y)
benchmark(
sum(d[dm, nomatch=0L, on="x"]$y),
d[dm, sum(y), nomatch=0L, on="x"],
replications = 5, columns = c("test", "replications", "elapsed", "relative"))
# test replications elapsed relative
#2 d[dm, sum(y), nomatch = 0, on = "x"] 5 36.113 1.000
#1 sum(d[dm, nomatch = 0, on = "x"]$y) 5 39.207 1.086
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment