Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ycai
simbricks
Commits
eed0b85b
"...git@developer.sourcefind.cn:OpenDAS/ollama.git" did not exist on "d3ad627423c822f192ecece1691683e666a72db6"
Commit
eed0b85b
authored
Nov 25, 2020
by
Hejing Li
Browse files
experiment log json file parser
parent
7f503244
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
50 additions
and
0 deletions
+50
-0
experiments/pyexps/log_parser.py
experiments/pyexps/log_parser.py
+50
-0
No files found.
experiments/pyexps/log_parser.py
0 → 100644
View file @
eed0b85b
import
sys
import
os
import
pathlib
import
shutil
import
json
# How to use
# $ python3 parser.py ../out/qemu-wire-ib-TCPs-1.json
#
log_file
=
sys
.
argv
[
1
]
log
=
open
(
log_file
,
'r'
)
curdir
=
pathlib
.
Path
().
absolute
()
exp_log
=
json
.
load
(
log
)
#Name, starting & ending time
exp_name
=
exp_log
[
'exp_name'
]
tooutdir
=
f
'../out/
{
exp_name
}
'
outdir
=
os
.
path
.
join
(
curdir
,
tooutdir
)
if
not
os
.
path
.
exists
(
outdir
):
raise
Exception
(
"no such directory"
)
start_end_path
=
os
.
path
.
join
(
outdir
,
'start_end.txt'
)
start_end_file
=
open
(
start_end_path
,
'w'
)
start_end_file
.
write
(
'start time: '
+
str
(
exp_log
[
"start_time"
])
+
'
\n
'
)
start_end_file
.
write
(
'end time: '
+
str
(
exp_log
[
"end_time"
])
+
'
\n
'
)
start_end_file
.
write
(
'success: '
+
str
(
exp_log
[
"success"
]))
start_end_file
.
close
()
for
i
in
exp_log
[
"sims"
]:
#print(i)
simdir
=
os
.
path
.
join
(
outdir
,
i
)
sim_out_file
=
open
(
simdir
,
'w'
)
for
j
in
exp_log
[
"sims"
][
i
]:
#print(j)
sim_out_file
.
write
(
j
+
'
\n
'
)
if
(
j
==
'class'
):
sim_out_file
.
write
(
exp_log
[
"sims"
][
i
][
j
]
+
'
\n
'
)
else
:
for
k
in
exp_log
[
"sims"
][
i
][
j
]:
sim_out_file
.
write
(
k
+
'
\n
'
)
sim_out_file
.
close
()
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