-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Dataset insertion benchmark #7223
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3273950
Add a benchmark for dataset element insertion
hmaarrfk 151b2a2
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 2837d95
Update asv_bench/benchmarks/dataset_creation.py
Illviljan cbd29aa
Rework the benchmark
hmaarrfk c7b3fb9
lint before the bot
hmaarrfk e2fbec4
Update asv_bench/benchmarks/dataset_creation.py
hmaarrfk b6bb7a8
Update asv_bench/benchmarks/dataset_creation.py
hmaarrfk ee83f2b
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] 7627fc9
Lint
hmaarrfk ba2e7ad
Rename the benchmark
hmaarrfk 33b6200
Rename benchmark
hmaarrfk b7582ae
Update asv_bench/benchmarks/dataset_in_memory_operation.py
hmaarrfk ee0cc92
Update and rename dataset_in_memory_operation.py to merge.py
dcherian 49e51d7
Merge branch 'main' into dataset_creation_benchmark
dcherian e328ebf
add back elements
hmaarrfk 4fe2deb
Only add a single variable
hmaarrfk 2fdf774
Give the parameter a name
hmaarrfk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import xarray as xr | ||
|
||
|
||
class DatasetAddVariable: | ||
param_names = ["existing_elements"] | ||
params = [[0, 10, 100, 1000]] | ||
|
||
def setup(self, existing_elements): | ||
self.datasets = {} | ||
# Dictionary insertion is fast(er) than xarray.Dataset insertion | ||
d = {} | ||
for i in range(existing_elements): | ||
d[f"var{i}"] = i | ||
self.dataset = xr.merge([d]) | ||
|
||
def time_variable_insertion(self, existin_elements): | ||
dataset = self.dataset | ||
dataset["new_var"] = 0 |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, i was going to expand this to other in-memory operations. Replace a variable? Drop a variable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought the first version used was relevant as well:
And this fast one from #7224 (comment) would also be nice to benchmark:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The first case is captured by cause i am suggesting we time insertion for 0, 10, 100, 1000 existing variable. One can interpolate the bahvior.
I do believe that bencharmming all at once creation (the second case) is also interesting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I renamed it thinking that we were really timing the
merge
operations. This is also true for replacing, but not true for dropping.Maybe we add dropping to a new
dataset.py
. This is all quite minor though! Shall we merge?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It depends if you want to think about from the point of view of "xarray developer" or "xarray user".
As an "xarray user", i'm trying to "insert a totally new variable, no dims, no coords". I don't really care what is happening under the hood. This is what I originally had in mind. This is h
My goal with the original name was to test operations on in-memory xarrays (as opposed to those backed by a file, which seem to be done in
dataset_io
). I don't know if I have time to "add other benchmarks" at the moment. This seems good.The name is the only thing that will survive. so if you are are ok with it.
I ran the benchmarks against main, #7221, and #7222. The benchmark seems to show the effect locally even with a single insertion. I've thus simplified the benchmark to do a single insertion, and not 5.
main
#7221
#7222
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way renameok i renamed it.param1
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.