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

QUERY: Are the benchmarking done sequentially? #1405

Open
officialasishkumar opened this issue Jun 8, 2024 · 5 comments
Open

QUERY: Are the benchmarking done sequentially? #1405

officialasishkumar opened this issue Jun 8, 2024 · 5 comments
Labels
question Triaged as a question, not requiring action after answering

Comments

@officialasishkumar
Copy link

I have a class like this. I want to do the benchmarking sequentially i.e. first time_FormalIntegrator_check, then time_FormalIntegrator_calculate_spectrum ans so on. Is there any way to do it?

class BenchmarkMontecarloMontecarloNumbaNumbaFormalIntegral(BenchmarkBase):
    def __init__(self):
        super().__init__()
        self.config = None

    def setup(self):
        filename = "data/tardis_configv1_benchmark.yml"
        path = self.get_relative_path(filename)
        self.config = Configuration.from_yaml(path)
        self.Simulation = run_tardis(
            self.config, log_level="ERROR", show_progress_bars=False
        )

        self.FormalIntegrator = formal_integral.FormalIntegrator(
            self.Simulation.simulation_state, self.Simulation.plasma, self.Simulation.transport
        )

    def time_FormalIntegrator_check(self) -> None:
        self.FormalIntegrator.check()

    def time_FormalIntegrator_calculate_spectrum(self) -> None:
        self.FormalIntegrator.calculate_spectrum(
            self.Simulation.transport.transport_state.spectrum.frequency
        )

    def time_FormalIntegrator_make_source_function(self) -> None:
        self.att_S_ul, self.Jredlu, self.Jbluelu, self.e_dot_u = self.FormalIntegrator.make_source_function()

    def time_FormalIntegrator_generate_numba_objects(self) -> None:
        self.FormalIntegrator.generate_numba_objects()
@HaoZeke
Copy link
Member

HaoZeke commented Jul 1, 2024

Is there a reason for wanting them to be done in order?

@HaoZeke HaoZeke changed the title Are the benchmarking done sequentially? QUERY: Are the benchmarking done sequentially? Jul 1, 2024
@officialasishkumar
Copy link
Author

@HaoZeke I have some functions that needs to be run before other functions. It's basically dependent on them.

@HaoZeke
Copy link
Member

HaoZeke commented Aug 11, 2024

@HaoZeke I have some functions that needs to be run before other functions. It's basically dependent on them.

Isn't that the use-case for the setup functions?

@HaoZeke HaoZeke added the question Triaged as a question, not requiring action after answering label Aug 12, 2024
@officialasishkumar
Copy link
Author

@HaoZeke I have some functions that needs to be run before other functions. It's basically dependent on them.

Isn't that the use-case for the setup functions?

Those functions also need to be benchmarked.

@HaoZeke
Copy link
Member

HaoZeke commented Aug 12, 2024

I think this might be a design issue. If you're benchmarking the sequence of functions then a simple lambda enclosing them should suffice? Or even a little utility function. eg. :

# pseudocode
def a():
  b() # setup
  c() # payload

# profile this with ASV
def tester():
 a()

Either that or I'd assume you could profile the setup separately for optimizing it, and have that separated from the c() function above, since they're separate tasks conceptually, i.e. how quickly c() works is independent or should be independent of how quickly b() is run.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Triaged as a question, not requiring action after answering
Projects
None yet
Development

No branches or pull requests

2 participants