Skip to content
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

Add official testing for Ruby 3.0 #101

Merged
merged 1 commit into from Feb 2, 2021
Merged

Add official testing for Ruby 3.0 #101

merged 1 commit into from Feb 2, 2021

Conversation

JacobEvelyn
Copy link
Member

@JacobEvelyn JacobEvelyn commented Jan 5, 2021

Before merging:

  • Copy the latest benchmark results into the README.md and update this PR
  • If this change merits an update to CHANGELOG.md, add an entry following Keep a Changelog guidelines with semantic versioning

@codecov
Copy link

codecov bot commented Jan 5, 2021

Codecov Report

Merging #101 (d5b4671) into main (4bdb862) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff            @@
##              main      #101   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines          621       621           
=========================================
  Hits           621       621           
Impacted Files Coverage Δ
lib/memo_wise.rb 100.00% <ø> (ø)

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 4bdb862...c8c5558. Read the comment docs.

@@ -78,20 +78,23 @@ For more usage details, see our detailed [documentation](#documentation).

## Benchmarks
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd recommend viewing either the rich diff or the end result rendered as markdown.

@@ -115,7 +121,7 @@ def positional_splat_keyword_and_double_splat_args(a, *args, b:, **kwargs)
# retrieval time.
instance.no_args

x.report("#{benchmark_gem.benchmark_name}: no_args") { instance.no_args }
x.report("#{benchmark_gem.benchmark_name}: ()") { instance.no_args }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the names of benchmarks to make it clearer where they go in the README.

) do
ARGUMENTS.each { |a, b| instance.positional_and_splat_args(a: a, b: b) }
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this was a bug! (It's calling the wrong method 😓)

) do
ARGUMENTS.each do |a, b|
instance.positional_and_splat_args(a, b, a: a, b: b)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another bug! (It's calling the wrong method 😓)

@@ -216,15 +224,15 @@ def positional_splat_keyword_and_double_splat_args(a, *args, b:, **kwargs)
# Run once with each set of arguments to memoize the result values, so our
# benchmark only tests memoized retrieval time.
ARGUMENTS.each do |a, b|
instance.positional_splat_keyword_and_double_splat_args(a, b, a: a, b: b)
instance.positional_splat_keyword_and_double_splat_args(a, b, b: b, a: a)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I switched the order of these args because b: b is the keyword arg and a: a is **kwargs and I'm worried that a: a, b: b might put them both in through **kwargs and bypass the keyword arg.

@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Logo
- Memoization of class methods
- Support for instances created with `Class#allocate`
- Official testing and benchmarks for Ruby 3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Worth noting that the code itself was also upgraded to have a ruby version of 3.0?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the .ruby-version file? I'm not sure that's useful, since that's only used for local development and not users of the gem or our automated tests. Or am I misunderstanding?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're totally right, good point, it's internal to the gem.


# Some gems do not yet work in Ruby 3 so we only require them if they're loaded
# in the Gemfile.
%w[memery memoist].each { |gem| require gem if Gem.loaded_specs.key?(gem) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No strong preference here either, but just looking again, could we include memoized and memoizer in the first line to make the second line also a one liner?

%w[memery memoist memoized memoizer].each { |gem| require gem if Gem.loaded_specs.key?(gem) }
# The VERSION constant does not get loaded above. 
%w[memoized memoizer].each { |gem| require "#{gem}/version"  if Gem.loaded_specs.key?(gem) }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice suggestion! Unfortunately those lines are too long. The best we could do would be:

# Some gems do not yet work in Ruby 3 so we only require them if they're loaded
# in the Gemfile.
%w[memery memoist memoized memoizer].
  each { |gem| require gem if Gem.loaded_specs.key?(gem) }

# The VERSION constant does not get loaded above.
%w[memoized memoizer].
  each { |gem| require "#{gem}/version" if Gem.loaded_specs.key?(gem) }

Up to you; I'm happy with whichever you prefer.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I like this better than what we have, if you don't mind changing it! Reads cleaner to me

@@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Logo
- Memoization of class methods
- Support for instances created with `Class#allocate`
- Official testing and benchmarks for Ruby 3.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No you're totally right, good point, it's internal to the gem.


# Some gems do not yet work in Ruby 3 so we only require them if they're loaded
# in the Gemfile.
%w[memery memoist].each { |gem| require gem if Gem.loaded_specs.key?(gem) }
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I like this better than what we have, if you don't mind changing it! Reads cleaner to me

Copy link
Contributor

@ms-ati ms-ati left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants