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

GSOC First Objective Tardis Benchmarking #2567

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .mailmap
Original file line number Diff line number Diff line change
Expand Up @@ -267,3 +267,5 @@ Kim Lingemann <[email protected]> kimsina <[email protected]>
Kim Lingemann <[email protected]> kim <[email protected]>

Sumit Gupta <[email protected]>

Rudraksh Nalbalwar <[email protected]> rudrakshnalbalwar <[email protected]>
38 changes: 38 additions & 0 deletions benchmarks/benchmark_visualization.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import timeit
import os
from tardis.io.configuration.config_reader import Configuration
from tardis import run_tardis
from tardis.visualization import ConvergencePlots
from astropy import units as u

class Benchmarkvisualizationplot:
"""Class to benchmark TARDIS simulation and data analysis functions."""

timeout = 200

def setup(self):
filename = "tardis_configv1_benchmark.yml"
dir_path = os.path.dirname(os.path.realpath(__file__))
path = os.path.join(dir_path, "data", filename)
self.config = Configuration.from_yaml(path)
self.config.atom_data = "kurucz_cd23_chianti_H_He.h5"
self.sim = run_tardis(self.config, log_level="ERROR", show_progress_bars=False)

def time_convergence_plot(self):
plotter = ConvergencePlots.create_plasma_plot(self.sim)

def benchmark_all(self):
"""Runs benchmarks for all functions and prints results."""
print("Benchmarking TARDIS simulation...")
setup_time = timeit.timeit(self.setup, number=1)
simulation_time = timeit.timeit(self.time_run_tardis, number=1)
print(f"Total setup time: {setup_time:.4f} seconds")
print(f"Simulation time: {simulation_time:.4f} seconds")

print("\nBenchmarking data analysis and visualization...")
visualization_time = timeit.timeit(self.time_convergence_plot, number=1)
print(f"Convergence plot time: {visualization_time:.4f} seconds")

if __name__ == "__main__":
benchmark = Benchmarkvisualizationplot()
benchmark.benchmark_all()
Loading