Skip to content

Commit

Permalink
cache in setup function
Browse files Browse the repository at this point in the history
Signed-off-by: Asish Kumar <[email protected]>
  • Loading branch information
officialasishkumar committed Aug 2, 2024
1 parent 7eff8e8 commit bf217a0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions benchmarks/transport_montecarlo_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,20 @@
Basic TARDIS Benchmark.
"""

import functools

import tardis.transport.montecarlo.interaction as interaction
from benchmarks.benchmark_base import BenchmarkBase


# check it
class BenchmarkTransportMontecarloInteraction(BenchmarkBase):
"""
Class to benchmark the numba interaction function.
"""

repeat = 3
repeat = 3

@functools.cache
def setup(self):
self.Packet = self.packet
self.time_explosion = self.verysimple_time_explosion
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/transport_montecarlo_main_loop.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
Basic TARDIS Benchmark.
"""

import functools

from benchmarks.benchmark_base import BenchmarkBase
from tardis.transport.montecarlo.montecarlo_main_loop import (
montecarlo_main_loop,
Expand All @@ -15,6 +17,7 @@ class to benchmark montecarlo_main_loop function.

repeat = 3

@functools.cache
def setup(self):
self.packet_collection = self.transport_state.packet_collection
self.geometry_state = self.transport_state.geometry_state
Expand Down
3 changes: 3 additions & 0 deletions benchmarks/transport_montecarlo_packet_trackers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
"""
Basic TARDIS Benchmark.
"""
import functools

from asv_runner.benchmarks.mark import parameterize

from benchmarks.benchmark_base import BenchmarkBase
Expand All @@ -15,6 +17,7 @@ class BenchmarkTransportMontecarloPacketTrackers(BenchmarkBase):

repeat = 2

@functools.cache
def setup(self, num_packets, length):
sim = self.simulation_rpacket_tracking_enabled
self.TransportState = sim.transport.transport_state
Expand Down

0 comments on commit bf217a0

Please sign in to comment.