[Rcpp-devel] Fwd: How can I avoid calls to coerceToReal
edd at debian.org
Tue Apr 30 17:43:17 CEST 2013
On 30 April 2013 at 11:19, Pratibha Rana wrote:
| MY application is performing really slow due to unnecessary calls to
| coerceToReal from this line NumericVector ocol = df[j]. Here is a sample
| of what I am doing. Is there a way to avoid the unnecessary overhead?
| Please note that the data in df is float data.
| void writeDataToPartitionWriter(DataFrame df, Writer
| NumericVector ocol = df[j];
| if(ocol[i] ==NA_REAL)
| res_writer.setFloat(j, vfloat_null);
| vfloat floatout = static_cast<vfloat>(ocol[i]);
| res_writer.setFloat(j, floatout);
Hard to really tell at this point but a few things come to mind:
a) if you know your data is float or double, store it as float or
b) R only has numeric, so if you want to save a few bytes, and save a
conversion, just use std::vector<float> from your data access to you
(internal?) Writer class.
Rcpp does a few things for your convenience, if your profiling reveals them
to be costly just try to do somehthing else...
Year ago, I wrote an (internal at my then-workplace) data accessor to a
(high-performance) column-data store from one of your main competitors. I
just kept everything in STL types til I returned the result home to R as a
Matrix, but I also simplified my case by assuming double for everything...
| Rcpp-devel mailing list
| Rcpp-devel at lists.r-forge.r-project.org
Dirk Eddelbuettel | edd at debian.org | http://dirk.eddelbuettel.com
More information about the Rcpp-devel