Skip to content

Commit

Permalink
Add benchmark test for parameter.add_data comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
glatterf42 committed Oct 1, 2024
1 parent 1e1fe65 commit bced419
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions tests/data/test_benchmark_optimization_parameter.py
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)

0 comments on commit bced419

Please sign in to comment.