Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

Commit

Permalink
fix(CodeChunk.duration): Recording duration in seconds rather than mi…
Browse files Browse the repository at this point in the history
…lliseconds
  • Loading branch information
beneboy committed Dec 17, 2019
1 parent 2cc6896 commit cfbc1dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions stencila/pyla/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ def __exit__(self, exc_type, exc_val, exc_tb):
self.duration = datetime.datetime.now() - self._start_time

@property
def duration_ms(self) -> float:
def duration_seconds(self) -> float:
"""Calculate the duration (time between `__enter__` and `__exit__` in microseconds."""
if not self.duration:
raise RuntimeError('CodeTimer has not yet been run')

return self.duration.total_seconds() * 1000
return self.duration.total_seconds()


class StdoutBuffer(TextIOWrapper):
Expand Down Expand Up @@ -374,7 +374,7 @@ def execute_statement(self, statement: ast.stmt, chunk: CodeChunk, _locals: typi
try:
with CodeTimer() as code_timer:
result = run_function(code_to_run, self.globals, _locals)
duration += code_timer.duration_ms
duration += code_timer.duration_seconds
# pylint: disable=W0703 # we really don't know what Exception some exec'd code might raise.
except Exception as exc:
error_occurred = True
Expand Down
2 changes: 1 addition & 1 deletion tests/test_interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def test_execute_compilation(mock_interpreter_class, mock_pp_class):

mock_pp_class.assert_called_with(compilation_result.parameters)
parameter_parser.parse_cli_args.assert_called_with(parameters)
interpreter.execute.assert_not_called() #Because nothing in compilation_result
interpreter.execute.assert_not_called() # Because nothing in compilation_result


def test_sempahore_skipping():
Expand Down

0 comments on commit cfbc1dc

Please sign in to comment.