Skip to content

Commit

Permalink
Make sure benchmarks are logged
Browse files Browse the repository at this point in the history
  • Loading branch information
gunthercox committed Jan 31, 2018
1 parent f8b2f7f commit 3bdaed7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 13 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description-file = README.md

[nosetests]
verbosity = 3
nocapture = true
exclude = (?:^tests_django$)
with-coverage = true
cover-package = chatterbot
Expand Down
15 changes: 2 additions & 13 deletions tests/test_benchmarks.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,26 +8,14 @@
from chatterbot import ChatBot
from chatterbot import utils
from factory import Faker
import sys
import logging


logging.basicConfig(
stream=sys.stdout,
level=logging.INFO
)

# Generate a list of random sentences
STATEMENT_LIST = Faker('sentences', nb=10).generate({})


class BenchmarkingMixin(object):

def setUp(self):
super(BenchmarkingMixin, self).setUp()

self.logger = logging.getLogger(__name__)

def get_kwargs(self):
kwargs = super(BenchmarkingMixin, self).get_kwargs()
kwargs['trainer'] = 'chatterbot.trainers.ListTrainer'
Expand All @@ -38,13 +26,14 @@ def assert_response_duration(self, maximum_duration, test_kwargs):
"""
Assert that the response time did not exceed the maximum allowed amount.
"""
from sys import stdout

chatbot = ChatBot('Benchmark', **test_kwargs)
chatbot.train(STATEMENT_LIST)

duration = utils.get_response_time(chatbot)

self.logger.info('Duration was %f seconds' % duration)
stdout.write('\nBENCHMARK: Duration was %f seconds\n' % duration)

if duration > maximum_duration:
raise AssertionError(
Expand Down

0 comments on commit 3bdaed7

Please sign in to comment.