-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add benchmark test for parameter.add_data comparison
- Loading branch information
1 parent
1e1fe65
commit bced419
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
"""These tests just benchmark pandas and in-DB-json editing for comparison.""" | ||
|
||
import ixmp4 | ||
|
||
from ..fixtures import BigOptimizationDataset | ||
|
||
|
||
class TestOptimizationParameter: | ||
data = BigOptimizationDataset() | ||
parameter_id: int | ||
|
||
def test_add_data(self, platform: ixmp4.Platform, profiled, benchmark): | ||
"""Benchmarks add_data using a large parameter.""" | ||
|
||
def setup(): | ||
self.data.load_units(platform) | ||
self.data.load_indexsets(platform) | ||
self.parameter_id = self.data.load_parameter(platform) | ||
return (platform,), {} | ||
|
||
def run(mp): | ||
with profiled(): | ||
self.data.insert_parameter_data(mp, self.parameter_id) | ||
self.data.upsert_parameter_data(mp, self.parameter_id) | ||
|
||
benchmark.pedantic(run, setup=setup) | ||
|
||
def test_add_data_json(self, platform: ixmp4.Platform, profiled, benchmark): | ||
"""Benchmarks add_data_json using a large parameter.""" | ||
|
||
def setup(): | ||
self.data.load_units(platform) | ||
self.data.load_indexsets(platform) | ||
self.parameter_id = self.data.load_parameter(platform) | ||
return (platform,), {} | ||
|
||
def run(mp): | ||
with profiled(): | ||
self.data.insert_parameter_data_json(mp, self.parameter_id) | ||
self.data.upsert_parameter_data_json(mp, self.parameter_id) | ||
|
||
benchmark.pedantic(run, setup=setup) |