Comments (1)
And now the timing comparisons:
Compile and load times
Compiling and loading the C
version is enormously faster than Rcpp
. Total compile-and-load times depend on whether it's done within the same R session or within a new one.
f <- function () {
pt <- proc.time ()
devtools::load_all (".", export_all = FALSE, recompile = TRUE)
print (proc.time () - pt)
}
Version | same R session? | time (s) |
---|---|---|
Rcpp | no | 5.67 |
Rcpp | yes | 5.29 |
C | no | 0.83 |
C | yes | 0.41 |
So compiling and loading package is around 10 times faster without Rcpp
.
Installed package sizes
I used this script to get the sizes of the installed packages:
install.packages("../geodist_0.0.0.9000.tar.gz")
library(fs)
library(tidyverse)
library(rvest)
installed.packages() %>%
as_data_frame() %>%
filter (Package == "geodist") %>%
mutate(pkg_dir =
sprintf("%s/%s", LibPath,
Package)) %>%
select(Package, pkg_dir) %>%
mutate(pkg_dir_size = map_dbl(pkg_dir, ~{ fs::dir_info(.x, all=TRUE,
recursive=TRUE) %>%
summarise(tot_dir_size = sum(size)) %>%
pull(tot_dir_size)
})) %>%
select (Package, pkg_dir_size)
Results:
Version | size (kB) |
---|---|
Rcpp | 176.955 |
C | 50.528 |
So Rcpp
inflates the package size to over three times. Finally, the most important comparison
Calculation speed
Based on the following function:
f <- function ()
{
n <- 1e3
x <- cbind (-180 + 360 * runif (n), -90 + 180 * runif (n))
y <- cbind (-180 + 360 * runif (2 * n), -90 + 180 * runif (2 * n))
colnames (x) <- colnames (y) <- c ("x", "y")
pt <- proc.time ()
for (i in 1:10)
{
d <- geodist (x, y)
}
pt <- proc.time () - pt
print (pt)
}
Version | same R session? | time (s) |
---|---|---|
Rcpp | no | 6.91 |
Rcpp | yes | 3.92 |
C | no | 2.61 |
C | yes | 2.32 |
And the C
version is definitely faster, but depends very much on whether repeats are conducted within the same R session or not. For a one-off calculation (that is, within a fresh session), the C
version is about 3 times faster, reducing to only about 40% faster if repeated within the same session. Either way, Rcpp
successfully ditched with some very positive results.
cc @karpfen
from geodist.
Related Issues (20)
- Min/Max Feature HOT 6
- Test georange sequential
- Sequential geodist produces different results to paired HOT 4
- DOC: "geodesic" is listed as "geodetic" in places HOT 1
- deploy pkgdown from travis
- Speed up R API by allowing direct submission of numeric vector objects HOT 13
- geodist gives different results for single row matrix with cheap ruler HOT 3
- Register C Callable HOT 5
- Thanks HOT 3
- Issue warning when cheapdist becomes inaccurate
- Update CRAN version with geodist_paired_vec HOT 6
- mention metres units in doc pages HOT 1
- meters instead of metres HOT 2
- Cheap is being expensive HOT 2
- geodist_max/min functions HOT 3
- error processing tibbles
- Updated version of package fails when y coordinate is called ymax HOT 4
- Request option not to warn when using cheap (or even test distances) HOT 2
- pkgcheck results - main HOT 9
- Fix package man entry
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from geodist.