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

Split Ruby code to match other languages #67

Merged
merged 5 commits into from
Jun 22, 2022

Conversation

eregon
Copy link
Contributor

@eregon eregon commented Jun 21, 2022

This is needed to integrate with polybench, cc @boris-spas.

Notably this makes it possible to run a benchmark without needing to run harness.rb, like:

require_relative 'run'

RUN = Run.new('Bounce')
RUN.num_iterations = 1
RUN.inner_iterations = 1

5.times do
  RUN.run_benchmark
end

eregon added 3 commits June 21, 2022 14:35
* require/require_relative raise LoadError if they cannott load the file.
* The difference is trivial and easily checked for.
* Same structure as in Python and Java.
* Makes it easy to not load harness.rb.
@eregon eregon force-pushed the ruby-harness-improvements branch from 70845b3 to 707bb75 Compare June 21, 2022 13:08
@eregon
Copy link
Contributor Author

eregon commented Jun 21, 2022

@smarr In CD, RuboCop is suggesting to change:

    # Y is guaranteed to be non-null at this point.
    if y.left
      x = y.left
    else
      x = y.right
    end

to

    # Y is guaranteed to be non-null at this point.
    x = y.left || y.right

I do that, or I add an ignore? (it is semantically equivalent, it avoids calling y.left twice)

@eregon eregon force-pushed the ruby-harness-improvements branch from 707bb75 to 6f127b3 Compare June 21, 2022 13:11
@smarr
Copy link
Owner

smarr commented Jun 21, 2022

    # Y is guaranteed to be non-null at this point.
    x = y.left || y.right

I do that, or I add an ignore? (it is semantically equivalent, it avoids calling y.left twice)

Hm, my feeling is that we would want a compiler to figure this out. So, I'd tent to disabling the relevant rubocop rule.

Copy link
Owner

@smarr smarr left a comment

Choose a reason for hiding this comment

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

Just for confirmation, this is just moving code around right?

@boris-spas mentioned in Potsdam that he indeed wanted to do that to replicate the same code structure as in the other languages.

So, yeah, that's great.

Thanks

benchmarks/Ruby/.rubocop.yml Show resolved Hide resolved
@eregon
Copy link
Contributor Author

eregon commented Jun 21, 2022

Just for confirmation, this is just moving code around right?

Mostly, yes. If you review commit-by-commit it's clearer what happens and what are the actual changes.

@eregon
Copy link
Contributor Author

eregon commented Jun 21, 2022

@boris-spas will double-check it works for polybench and then it should be ready to merged (that's why it's a draft PR currently).

@boris-spas
Copy link

LGTM! Polybench happily works with

require(PATH_TO_AWFY_BENCHMARKS_RUBY + "/run")

RUN = Run.new('Bounce')
RUN.num_iterations = 1
RUN.inner_iterations = 1

def run()
    RUN.run_benchmark
end

@eregon eregon marked this pull request as ready for review June 22, 2022 11:00
@eregon
Copy link
Contributor Author

eregon commented Jun 22, 2022

Ready to be merged then

@smarr
Copy link
Owner

smarr commented Jun 22, 2022

Thank you!

@smarr smarr merged commit fbe00c8 into smarr:master Jun 22, 2022
@smarr smarr changed the title Ruby harness improvements Split Ruby code to match other languages Jun 22, 2022
@eregon eregon deleted the ruby-harness-improvements branch June 22, 2022 15:50
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.

3 participants