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

Convert POSIXct to Date directly #2

Merged
merged 1 commit into from Oct 20, 2018

Conversation

Projects
None yet
3 participants
@joshuaulrich
Contributor

joshuaulrich commented Oct 20, 2018

As of R-3.5.1, converting from POSIXct to Date creates an intermediate
POSIXlt vector. This uses a non-trivial amount of memory. Directly
converting from POSIXct to Date uses less memory and is roughly twice
as fast.

This solution is a combination of asPOSIXlt and POSIXlt2D from RCore.
The functions are essentially concatenated, with the extraneous parts
removed.

The function name 'asDatePOSIXct' differs from the other rapi* names
because it's not a RCore function. The name isn't as.Date.POSIXct() to
avoid clashes with the current (or future) S3 method.

Convert POSIXct to Date directly
As of R-3.5.1, converting from POSIXct to Date creates an intermediate
POSIXlt vector. This uses a non-trivial amount of memory. Directly
converting from POSIXct to Date uses less memory and is roughly twice
as fast.

This solution is a combination of asPOSIXlt and POSIXlt2D from RCore.
The functions are essentially concatenated, with the extraneous parts
removed.

The function name 'asDatePOSIXct' differs from the other rapi* names
because it's not a RCore function. The name isn't as.Date.POSIXct() to
avoid clashes with the current (or future) S3 method.
@codecov-io

This comment has been minimized.

codecov-io commented Oct 20, 2018

Codecov Report

Merging #2 into master will increase coverage by 1.42%.
The diff coverage is 84.78%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master       #2      +/-   ##
==========================================
+ Coverage   53.24%   54.67%   +1.42%     
==========================================
  Files           5        6       +1     
  Lines         971     1017      +46     
==========================================
+ Hits          517      556      +39     
- Misses        454      461       +7
Impacted Files Coverage Δ
R/asDatePOSIXct.R 100% <100%> (ø)
src/init.c 100% <100%> (ø) ⬆️
src/datetime.c 66.71% <82.05%> (+0.97%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 84aa1b0...6bc9320. Read the comment docs.

@eddelbuettel

Looks fabulous, and helpful.

@eddelbuettel eddelbuettel merged commit ad44621 into eddelbuettel:master Oct 20, 2018

3 checks passed

codecov/patch 84.78% of diff hit (target 53.24%)
Details
codecov/project 54.67% (+1.42%) compared to 84aa1b0
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@joshuaulrich joshuaulrich deleted the joshuaulrich:asDate-POSIXct branch Oct 20, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment