8000 benchmark-base-case by z00sts · Pull Request #112 · 2gis/contesto · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

benchmark-base-case #112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 17, 2017
Merged

benchmark-base-case #112

merged 2 commits into from
Mar 17, 2017

Conversation

z00sts
Copy link
Contributor
@z00sts z00sts commented Mar 13, 2017

Exception example:

contesto.utils.log: DEBUG: Benchmark iter 1
contesto.utils.log: DEBUG: Benchmark iter 2
contesto.utils.log: ERROR: Benchmark iter 2 exception:
Traceback (most recent call last):
  File "/home/s.zubov/repo/contesto/contesto/basis/benchmark.py", line 18, in run_multiple_times
    res = self._single_method()
  File "/home/s.zubov/repo/contesto/examples/benchmark_example.py", line 29, in test_benchmark_app_start
    raise Exception('OMG!')
Exception: OMG!

@z00sts z00sts changed the title [WIP] benchmark-base-case benchmark-base-case Mar 14, 2017
result.addError(self, sys.exc_info())
else:
for i in range(count):
print('make benchmark iter {}'.format(i))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А че print?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Эт именно чтоб в аутпуте всё увидеть без приседаний, нужно заменить

class BenchmarkBaseCase(ContestoTestCase):
def __init__(self, test_name='runTest'):
super(BenchmarkBaseCase, self).__init__(test_name)
self.run_count = getattr(config, 'benchmark').get('run_count', 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Если config не имеет benchmark, то упадем с ошибкой
Можно сделать лучше, так хоть дефолтное значение "1" всегда подставится

getattr(config, 'benchmark', {}).get('run_count', 1)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Согласен

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Хотя нет. Тогда придется везде так делать. Проще добавить в core.config секцию benchmark и он всегда будет в конфиге.

setattr(self, self._testMethodName, self._run_test_error_handlers(test_method))
setattr(self, 'setUp', self._run_test_error_handlers(self.setUp))
setattr(self, 'tearDown', self._run_test_error_handlers(self.tearDown))
self._run(result, self.run_count)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А почему внутри _run не получил свойство self.count? Зачем передавать так?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Просто так можно тогда убрать метод run

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно в принципе, я подумал так наглядней будет

10000
self._resultForDoCleanups = result
result.startTest(self)

testMethod = getattr(self, self._testMethodName)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

А что если сделать декоратор для self._testMethodName, переопределив его в init? Тогда может без переопределения run и _run обойтись? Что думаешь?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Идея, попробую

@z00sts z00sts force-pushed the benchmark-base-case branch 3 times, most recently from a7f7497 to 7bcf27f Compare March 15, 2017 05:47
res = self._single_method()
return res

def run(self, result=None):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не могу понять, а run() разве теперь нужно переопределять?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

забыл! спасибо

for i in range(self.run_count):
print('make benchmark iter {}'.format(i))
res = self._single_method()
return res
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Давай тесты напишем на этот класс?

Copy link
Contributor Author
@z00sts z00sts Mar 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

поддерживаю

@z00sts z00sts force-pushed the benchmark-base-case branch from 7bcf27f to 39835ce Compare March 15, 2017 07:30
@z00sts z00sts requested a review from skyline-gleb March 15, 2017 07:44
@z00sts z00sts force-pushed the benchmark-base-case branch from e2d16f7 to 6aa1006 Compare March 16, 2017 08:36
@z00sts z00sts force-pushed the benchmark-base-case branch from 6aa1006 to 0f4ff69 Compare March 16, 2017 09:06
@z00sts z00sts merged commit d68ae95 into master Mar 17, 2017
@z00sts z00sts deleted the benchmark-base-case branch March 24, 2017 04:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0