Performance of vec_fmt_*() by avoiding checking of compatibility + coercion to tibble#1893
Merged
Conversation
olivroy
commented
Sep 26, 2024
| Code | ||
| cols_add(tbl, x = 1, .after = 15) | ||
| Condition | ||
| Error in `vars_select_eval()`: |
Collaborator
Author
There was a problem hiding this comment.
Snapshot will be improved by r-lib/tidyselect#352 when merged
Comment on lines
+111
to
+121
| # Or if we are confident that we have a compatible formatter and no rows /cols are hidden | ||
| if ( | ||
| col %in% colnames(data_tbl) && | ||
| is_compatible_formatter( | ||
| table = data_tbl, | ||
| column = col, | ||
| rows = rows, | ||
| compat = compat | ||
| skip_compat_check || | ||
| ( | ||
| col %in% colnames(data_tbl) && | ||
| is_compatible_formatter( | ||
| table = data_tbl, | ||
| column = col, | ||
| rows = rows, | ||
| compat = compat | ||
| ) |
Collaborator
Author
There was a problem hiding this comment.
I added this to skip this check for vec_fmt_*
| @@ -226,9 +226,9 @@ tf_formats <- function() { | |||
|
|
|||
| dplyr::tribble( | |||
Collaborator
Author
There was a problem hiding this comment.
Before, it seemed that tf_formats_icons() included NAs, not sure what the impact of all this is tbh.
Now, it is:
tf_formats_icons()
[1] "c(\"✔\", \"✘\")" "c(\"●\", \"⭘\")" "c(\"■\", \"□\")" "c(\"◆\", \"◇\")" "c(\"↑\", \"↓\")" "c(\"▲\", \"▼\")"
[7] "c(\"▶\", \"◀\")"
which seems to make sense?
Member
There was a problem hiding this comment.
Thanks for adding omit_na()! Yeah, this return value is correct now but AFAICT nothing in the package uses tf_formats_icons() (so I guess no impact).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hopefully, my last one.
My example is down to about 4 seconds rendering time.
The main idea is to avoid dplyr or coercion to tibble and also avoid to check for the compatibility of the formatter unnecessarily.
I realized
cols_add()has some issues, so I fixed up the two corner cases.before = 0and.after = last_col()+ added tests.Also eliminated some tidyselect deprecation warnings
Related GitHub Issues and PRs
vec_*()functions. #1888 , Improve performance of vec_fmt_*() by not building the full data #1891My profiling is now

Last possible way to improve performance would be to have a minimal

gt_one_col()function that doesn't callgt()directlyThe
gt()calls take about a third of time with all its checks.Also avoiding the resolvers would be great, but would require work.