-
Notifications
You must be signed in to change notification settings - Fork 8
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
benchmark-base-case #112
Conversation
contesto/basis/benchmark.py
Outdated
result.addError(self, sys.exc_info()) | ||
else: | ||
for i in range(count): | ||
print('make benchmark iter {}'.format(i)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А че print?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Эт именно чтоб в аутпуте всё увидеть без приседаний, нужно заменить
contesto/basis/benchmark.py
Outdated
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) |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Согласен
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Хотя нет. Тогда придется везде так делать. Проще добавить в core.config секцию benchmark и он всегда будет в конфиге.
contesto/basis/benchmark.py
Outdated
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему внутри _run не получил свойство self.count? Зачем передавать так?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Просто так можно тогда убрать метод run
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Можно в принципе, я подумал так наглядней будет
contesto/basis/benchmark.py
Outdated
10000
self._resultForDoCleanups = result | ||
result.startTest(self) | ||
|
||
testMethod = getattr(self, self._testMethodName) |
There was a problem hiding this comment.
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 обойтись? Что думаешь?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Идея, попробую
a7f7497
to
7bcf27f
Compare
contesto/basis/benchmark.py
Outdated
res = self._single_method() | ||
return res | ||
|
||
def run(self, result=None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
не могу понять, а run() разве теперь нужно переопределять?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
забыл! спасибо
contesto/basis/benchmark.py
Outdated
for i in range(self.run_count): | ||
print('make benchmark iter {}'.format(i)) | ||
res = self._single_method() | ||
return res |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Давай тесты напишем на этот класс?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
поддерживаю
7bcf27f
to
39835ce
Compare
e2d16f7
to
6aa1006
Compare
6aa1006
to
0f4ff69
Compare
Exception example: