Skip to content

Commit

Permalink
owkmeans: add benchmark
Browse files Browse the repository at this point in the history
  • Loading branch information
markotoplak committed Mar 17, 2020
1 parent 66dad05 commit cce48e4
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions benchmark/bench_owkmeans.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
import numpy as np

from Orange.data import Domain, Table, ContinuousVariable
from Orange.widgets.tests.base import WidgetTest
from Orange.widgets.unsupervised.owkmeans import OWKMeans

from .base import benchmark


def table(rows, cols):
return Table.from_numpy( # pylint: disable=W0201
Domain([ContinuousVariable(str(i)) for i in range(cols)]),
np.random.RandomState(0).rand(rows, cols))


class BenchOWKmeans(WidgetTest):

@classmethod
def setUpClass(cls):
super().setUpClass()
cls.d_100_100 = table(100, 100)
cls.d_sampled_silhouette = table(10000, 1)
cls.d_10_500 = table(10, 500)

def setUp(self):
self.widget = None # to avoid lint errors

def widget_from_to(self):
self.widget = self.create_widget(
OWKMeans, stored_settings={"auto_commit": False})
self.widget.controls.k_from.setValue(2)
self.widget.controls.k_to.setValue(6)

@benchmark(number=3, warmup=1, repeat=3)
def bench_from_to_100_100(self):
self.widget_from_to()
self.send_signal(self.widget.Inputs.data, self.d_100_100)
self.commit_and_wait(wait=100*1000)

@benchmark(number=3, warmup=1, repeat=3)
def bench_from_to_100_100_no_normalize(self):
self.widget_from_to()
self.widget.normalize = False
self.send_signal(self.widget.Inputs.data, self.d_100_100)
self.commit_and_wait(wait=100*1000)

@benchmark(number=3, warmup=1, repeat=3)
def bench_from_to_sampled_silhouette(self):
self.widget_from_to()
self.send_signal(self.widget.Inputs.data, self.d_sampled_silhouette)
self.commit_and_wait(wait=100*1000)

@benchmark(number=3, warmup=1, repeat=3)
def bench_wide(self):
self.widget = self.create_widget(
OWKMeans, stored_settings={"auto_commit": False})
self.send_signal(self.widget.Inputs.data, self.d_10_500)
self.commit_and_wait(wait=100*1000)

0 comments on commit cce48e4

Please sign in to comment.