Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
code_block_timer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
code_block_timer
Commits
5c83d17e
Commit
5c83d17e
authored
Dec 16, 2014
by
John Eskew
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix module-wide nest_level var
parent
152f7d86
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
5 deletions
+10
-5
code_block_timer/__init__.py
+10
-5
No files found.
code_block_timer/__init__.py
View file @
5c83d17e
...
...
@@ -3,7 +3,12 @@ from timeit import default_timer
from
.storage
import
TimingDataStorage
nest_level
=
0
class
Globals
(
object
):
pass
__m
=
Globals
()
__m
.
nest_level
=
0
class
CodeBlockTimer
(
object
):
def
__init__
(
self
,
block_desc
,
verbose
=
False
):
...
...
@@ -14,9 +19,9 @@ class CodeBlockTimer(object):
self
.
run_id
=
None
def
__enter__
(
self
):
if
nest_level
==
0
:
if
__m
.
nest_level
==
0
:
self
.
run_id
=
self
.
data_store
.
run_id
()
nest_level
+=
1
__m
.
nest_level
+=
1
self
.
start
=
self
.
timer
()
return
self
...
...
@@ -25,8 +30,8 @@ class CodeBlockTimer(object):
self
.
elapsed_secs
=
end
-
self
.
start
self
.
elapsed
=
self
.
elapsed_secs
*
1000
# millisecs
self
.
data_store
.
store
(
self
.
run_id
,
self
.
block_desc
,
self
.
elapsed
)
nest_level
-=
1
if
nest_level
==
0
:
__m
.
nest_level
-=
1
if
__m
.
nest_level
==
0
:
self
.
run_id
=
None
if
self
.
verbose
:
print
'{}: elapsed time: {} ms'
.
format
(
self
.
block_desc
,
self
.
elapsed
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment