Skip to content

Commit

Permalink
Remove parameters and speed up benchmarks (#2717)
Browse files Browse the repository at this point in the history
* remove parameters and speed up benchmarks

Signed-off-by: Asish Kumar <[email protected]>

* asv run for 4 commits

Signed-off-by: Asish Kumar <[email protected]>

---------

Signed-off-by: Asish Kumar <[email protected]>
  • Loading branch information
officialasishkumar authored Jul 19, 2024
1 parent fed035e commit 491eb67
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 77 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ jobs:
- name: Run benchmarks for last 5 commits if not PR
if: github.event_name != 'pull_request_target'
run: |
git log -n 5 --pretty=format:"%H" >> tag_commits.txt
asv run HASHFILE:tag_commits.txt | tee asv-output.log
git log -n 4 --pretty=format:"%H" >> tag_commits.txt
asv run -a repeat=1 -a rounds=1 HASHFILE:tag_commits.txt | tee asv-output.log
if grep -q failed asv-output.log; then
echo "Some benchmarks have failed!"
exit 1
Expand Down Expand Up @@ -126,7 +126,7 @@ jobs:
echo $(git rev-parse HEAD) > commit_hashes.txt
echo $(git merge-base HEAD upstream/master) >> commit_hashes.txt
asv run HASHFILE:commit_hashes.txt | tee asv-output-PR.log
asv run -a repeat=1 -a rounds=1 HASHFILE:commit_hashes.txt | tee asv-output-PR.log
if grep -q failed asv-output-PR.log; then
echo "Some benchmarks have failed!"
exit 1
Expand Down
13 changes: 1 addition & 12 deletions benchmarks/transport_montecarlo_interaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ def time_thomson_scatter(self):
{
"Line interaction type": [
LineInteractionType.SCATTER,
LineInteractionType.DOWNBRANCH,
LineInteractionType.MACROATOM,
],
}
Expand Down Expand Up @@ -60,17 +59,7 @@ def time_line_scatter(self, line_interaction_type):
"mu": 0.8599443103322428,
"emission_line_id": 1000,
"energy": 0.9114437898710559,
},
{
"mu": -0.6975116557422458,
"emission_line_id": 2000,
"energy": 0.8803098648913266,
},
{
"mu": -0.7115661419975774,
"emission_line_id": 0,
"energy": 0.8800385929341252,
},
}
]
}
)
Expand Down
2 changes: 1 addition & 1 deletion benchmarks/transport_montecarlo_numba_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BenchmarkMontecarloMontecarloNumbaNumbaInterface(BenchmarkBase):
Class to benchmark the numba interface function.
"""

@parameterize({"Input params": ["scatter", "macroatom", "downbranch"]})
@parameterize({"Input params": ["scatter", "macroatom"]})
def time_opacity_state_initialize(self, input_params):
line_interaction_type = input_params
plasma = self.nb_simulation_verysimple.plasma
Expand Down
106 changes: 62 additions & 44 deletions benchmarks/transport_montecarlo_opacities.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,58 +34,76 @@ def time_compton_opacity_calculation(self, electron_number_density, energy):

@parameterize(
{
"Ejecta density": [
1.0,
1e-2,
1e-2,
1e5,
],
"Energy": [
511.0,
255.5,
255.5,
511.0e7,
],
"Iron group fraction": [
0.0,
0.5,
0.25,
1.0,
],
"Parameters": [
{
"Ejecta_density": 0.01,
"Energy": 511.0,
"Iron_group_fraction": 0.5,
},
{
"Ejecta_density": 0.01,
"Energy": 5110000000.0,
"Iron_group_fraction": 0.0,
},
{
"Ejecta_density": 0.01,
"Energy": 255.5,
"Iron_group_fraction": 0.0,
},
{
"Ejecta_density": 0.01,
"Energy": 255.5,
"Iron_group_fraction": 0.5,
},
{
"Ejecta_density": 100000.0,
"Energy": 255.5,
"Iron_group_fraction": 1.0,
}
]
}
)
def time_photoabsorption_opacity_calculation(
self, ejecta_density, energy, iron_group_fraction
):
def time_photoabsorption_opacity_calculation(self, parameters):
calculate_opacity.photoabsorption_opacity_calculation(
energy, ejecta_density, iron_group_fraction
parameters["Energy"],
parameters["Ejecta_density"],
parameters["Iron_group_fraction"],
)

@parameterize(
{
"Ejecta density": [
1.0,
1e-2,
1e-2,
1e5,
],
"Energy": [
511.0,
1500,
1200,
511.0e7,
],
"Iron group fraction": [
0.0,
0.5,
0.25,
1.0,
],
"Parameters": [
{
"Ejecta_density": 0.01,
"Energy": 511.0,
"Iron_group_fraction": 0.5,
},
{
"Ejecta_density": 0.01,
"Energy": 5110000000.0,
"Iron_group_fraction": 0.0,
},
{
"Ejecta_density": 0.01,
"Energy": 255.5,
"Iron_group_fraction": 0.0,
},
{
"Ejecta_density": 0.01,
"Energy": 255.5,
"Iron_group_fraction": 0.5,
},
{
"Ejecta_density": 100000.0,
"Energy": 255.5,
"Iron_group_fraction": 1.0,
}
]
}
)
def time_pair_creation_opacity_calculation(
self, ejecta_density, energy, iron_group_fraction
):
def time_pair_creation_opacity_calculation(self, parameters):
calculate_opacity.pair_creation_opacity_calculation(
energy, ejecta_density, iron_group_fraction
parameters["Energy"],
parameters["Ejecta_density"],
parameters["Iron_group_fraction"],
)
15 changes: 0 additions & 15 deletions benchmarks/transport_montecarlo_packet.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,6 @@ def time_update_line_estimators(self, parameters):
"delta_shell": 11,
"no_of_shells": 132,
},
{
"current_shell_id": 132,
"delta_shell": 1,
"no_of_shells": 133,
},
{
"current_shell_id": 132,
"delta_shell": 2,
Expand All @@ -146,11 +141,6 @@ def time_move_packet_across_shell_boundary_emitted(self, parameters):
"delta_shell": 132,
"no_of_shells": 132,
},
{
"current_shell_id": -133,
"delta_shell": -133,
"no_of_shells": -1e9,
},
{
"current_shell_id": 132,
"delta_shell": 133,
Expand Down Expand Up @@ -182,11 +172,6 @@ def time_move_packet_across_shell_boundary_reabsorbed(self, parameters):
"delta_shell": 0,
"no_of_shells": 132,
},
{
"current_shell_id": 132,
"delta_shell": 20,
"no_of_shells": 154,
},
]
}
)
Expand Down
3 changes: 1 addition & 2 deletions benchmarks/transport_montecarlo_vpacket.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,5 @@ def time_trace_vpacket_volley(self, parameters):
self.verysimple_opacity_state,
False,
parameters["tau_russian"],
parameters["survival_possibility"],
False,
parameters["survival_possibility"]
)

0 comments on commit 491eb67

Please sign in to comment.