-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
colour conversions #14
Milestone
Comments
new col <- "#00FF00FF"
col <- rep(col, 1e6)
library(microbenchmark)
microbenchmark(
cv = { colourvalues:::rcpp_convert_hex_to_rgb_new( col) },
cv_old = { colourvalues:::rcpp_convert_hex_to_rgb( col ) },
gr = { grDevices::col2rgb(col, alpha = TRUE) },
times = 10
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# cv 30.81213 32.73352 47.4408 35.59811 76.95149 81.37984 10
# cv_old 272.52093 276.65413 290.7468 285.09019 295.67034 327.61521 10
# gr 36.80980 39.10075 41.6736 41.57528 44.91530 46.51591 10 |
SymbolixAU
pushed a commit
that referenced
this issue
Oct 9, 2018
and the other way rgb2hex <- function(m) grDevices::rgb(m[,1], m[,2], m[,3], m[,4], maxColorValue = 255)
m <- matrix(c(255,170,0,255),ncol = 4)
n <- 1e6
m <- m[rep(1,n),]
r <- rep(255, n)
g <- rep(170, n)
b <- rep(0, n)
a <- rep(255, n)
microbenchmark(
gr = { rgb2hex(m) },
gr2 = { rgb(r,g,b,a, maxColorValue = 255) },
cv = { colourvalues:::rcpp_convert_rgb_to_hex(m) },
times = 10
)
# Unit: milliseconds
# expr min lq mean median uq max neval
# gr 92.93735 97.36313 105.60413 100.61244 104.47904 152.06389 10
# gr2 77.65241 80.03476 93.30192 85.64504 90.76205 131.98374 10
# cv 78.46464 78.81009 83.86777 81.85836 87.48609 94.67922 10 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
None yet
0 participants
TODO
The text was updated successfully, but these errors were encountered: