Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
lp_nn_robustness_verification
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ludwig10_masters_thesis
lp_nn_robustness_verification
Commits
dddd24d1
Verified
Commit
dddd24d1
authored
2 years ago
by
Björn Ludwig
Browse files
Options
Downloads
Patches
Plain Diff
feat(timing): introduce module to time and store progress
parent
f8aee652
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/lp_nn_robustness_verification/timing.py
+43
-0
43 additions, 0 deletions
src/lp_nn_robustness_verification/timing.py
with
43 additions
and
0 deletions
src/lp_nn_robustness_verification/timing.py
0 → 100644
+
43
−
0
View file @
dddd24d1
"""
Time the current progress of model preprocessing setup or any part of the process
"""
__all__
=
[
"
write_current_timing_stats
"
]
from
io
import
StringIO
import
yappi
# type: ignore[import]
def
write_current_timing_stats
(
filename
:
str
=
"
timings.txt
"
,
msg
:
str
=
""
,
mode
:
str
=
"
a
"
)
->
None
:
"""
Write current content of ``yappi.YStat`` object to file
Only useful, if in the current execution context ``yappi.start()`` was called
beforehand, so no file is created otherwise and nothing is written anywhere.
Parameters
----------
filename : str, optional
destination file name, can be relative to current working directory,
defaults to
"
timings.txt
"
msg : str, optional
an additional message to be written to the file before the stats are written,
defaults to empty string
mode : str, optional
mode for opening and writing to file, same as with :func:`open()`, defaults
to
"
a
"
"""
out
=
StringIO
()
yappi
.
get_func_stats
().
print_all
(
out
=
out
,
columns
=
{
0
:
(
"
name
"
,
170
),
3
:
(
"
ttot
"
,
8
)}
)
if
out
.
getvalue
():
with
open
(
filename
,
mode
,
encoding
=
"
utf-8
"
)
as
timings_file
:
timings_file
.
write
(
f
"
\n
===========================================================
"
f
"
===========================
\n\n
"
f
"
Timings for
{
filename
}
\n
{
msg
}
"
f
"
\n
===========================================================
"
f
"
===========================
\n
"
)
timings_file
.
write
(
out
.
getvalue
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment