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

ENH: Add a skip_benchmark_if and skip_params_if #17

Merged
merged 3 commits into from
Aug 13, 2023

Conversation

HaoZeke
Copy link
Member

@HaoZeke HaoZeke commented Jul 22, 2023

Closes #16.

from asv_runner.benchmarks.mark import skip_benchmark_if, skip_params_if
import datetime

class TimeSuite:
    """
    An example benchmark that times the performance of various kinds
    of iterating over dictionaries in Python.
    """
    params = [100, 200, 300, 400, 500]
    param_names = ["size"]

    def setup(self, size):
        self.d = {}
        for x in range(size):
            self.d[x] = None

    @skip_benchmark_if(datetime.datetime.now().hour >= 12)
    def time_keys(self, size):
        for key in self.d.keys():
            pass

    @skip_benchmark_if(datetime.datetime.now().hour >= 12)
    def time_values(self, size):
        for value in self.d.values():
            pass

    @skip_benchmark_if(datetime.datetime.now().hour >= 12)
    def time_range(self, size):
        d = self.d
        for key in range(size):
            d[key]

    # Skip benchmarking when size is either 100 or 200 and the current hour is 12 or later.
    @skip_params_if([(100,), (200,)],
                    datetime.datetime.now().hour >= 12)
    def time_dict_update(self, size):
        d = self.d
        for i in range(size):
            d[i] = i

@HaoZeke
Copy link
Member Author

HaoZeke commented Jul 22, 2023

@akihironitta this should cover the checks for CUDA or other conditionals

Copy link

@akihironitta akihironitta left a comment

Choose a reason for hiding this comment

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

Hi @HaoZeke, thank you so much for working on this! I'll give this a try tomorrow. Do you think we should have tests in this repo?

@HaoZeke
Copy link
Member Author

HaoZeke commented Aug 7, 2023

Hi @HaoZeke, thank you so much for working on this! I'll give this a try tomorrow. Do you think we should have tests in this repo?

I'm not very sure about having tests here, or rather I'm not exactly sure what the best kind of tests would be, since checking the behavior would have to be done with asv, not asv_runner and testing the decorators wouldn't make much sense.

@HaoZeke HaoZeke merged commit 154e23e into airspeed-velocity:main Aug 13, 2023
5 checks passed
@HaoZeke HaoZeke deleted the skipif branch August 13, 2023 14:31
@HaoZeke HaoZeke mentioned this pull request Aug 13, 2023
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.

ENH: More skip conditionals
2 participants