Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
riscv-gcc-1
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
lvzhengyang
riscv-gcc-1
Commits
0d73e480
Commit
0d73e480
authored
Jun 09, 2016
by
Martin Liska
Committed by
Martin Liska
Jun 09, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add sorting support to analyze_brprob script
* analyze_brprob.py: Add new argument --sorting. From-SVN: r237256
parent
e49efc14
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
7 deletions
+23
-7
contrib/ChangeLog
+4
-0
contrib/analyze_brprob.py
+19
-7
No files found.
contrib/ChangeLog
View file @
0d73e480
2016
-
06
-
09
Martin
Liska
<
mliska
@suse
.
cz
>
*
analyze_brprob
.
py
:
Add
new
argument
--
sorting
.
2016
-
06
-
09
Martin
Liska
<
mliska
@suse
.
cz
>
*
analyze_brprob
.
py
:
Cover
new
dump
output
format
.
2016
-
06
-
07
Rainer
Orth
<
ro
@CeBiTec
.
Uni
-
Bielefeld
.
DE
>
...
...
contrib/analyze_brprob.py
View file @
0d73e480
...
...
@@ -65,6 +65,7 @@
import
sys
import
os
import
re
import
argparse
def
percentage
(
a
,
b
):
return
100.0
*
a
/
b
...
...
@@ -77,6 +78,9 @@ class Summary:
self
.
hits
=
0
self
.
fits
=
0
def
get_hitrate
(
self
):
return
self
.
hits
/
self
.
count
def
count_formatted
(
self
):
v
=
self
.
count
for
unit
in
[
''
,
'K'
,
'M'
,
'G'
,
'T'
,
'P'
,
'E'
,
'Z'
]:
...
...
@@ -108,22 +112,30 @@ class Profile:
def
count_max
(
self
):
return
max
([
v
.
count
for
k
,
v
in
self
.
heuristics
.
items
()])
def
dump
(
self
):
def
dump
(
self
,
sorting
):
sorter
=
lambda
x
:
x
[
1
]
.
branches
if
sorting
==
'hitrate'
:
sorter
=
lambda
x
:
x
[
1
]
.
get_hitrate
()
elif
sorting
==
'coverage'
:
sorter
=
lambda
x
:
x
[
1
]
.
count
print
(
'
%-36
s
%8
s
%6
s
%-16
s
%14
s
%8
s
%6
s'
%
(
'HEURISTICS'
,
'BRANCHES'
,
'(REL)'
,
'HITRATE'
,
'COVERAGE'
,
'COVERAGE'
,
'(REL)'
))
for
(
k
,
v
)
in
sorted
(
self
.
heuristics
.
items
(),
key
=
lambda
x
:
x
[
1
]
.
branches
):
for
(
k
,
v
)
in
sorted
(
self
.
heuristics
.
items
(),
key
=
sorter
):
print
(
'
%-36
s
%8
i
%5.1
f
%% %6.2
f
%%
/
%6.2
f
%% %14
i
%8
s
%5.1
f
%%
'
%
(
k
,
v
.
branches
,
percentage
(
v
.
branches
,
self
.
branches_max
()),
percentage
(
v
.
hits
,
v
.
count
),
percentage
(
v
.
fits
,
v
.
count
),
v
.
count
,
v
.
count_formatted
(),
percentage
(
v
.
count
,
self
.
count_max
())
))
if
len
(
sys
.
argv
)
!=
2
:
print
(
'Usage: ./analyze_brprob.py dump_file'
)
exit
(
1
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'dump_file'
,
metavar
=
'dump_file'
,
help
=
'IPA profile dump file'
)
parser
.
add_argument
(
'-s'
,
'--sorting'
,
dest
=
'sorting'
,
choices
=
[
'branches'
,
'hitrate'
,
'coverage'
],
default
=
'branches'
)
args
=
parser
.
parse_args
()
profile
=
Profile
(
sys
.
argv
[
1
])
r
=
re
.
compile
(
' (.*) heuristics( of edge [0-9]*->[0-9]*)?(
\\
(.*
\\
))?: (.*)
%.*
exec ([0-9]*) hit ([0-9]*)'
)
for
l
in
open
(
profile
.
filenam
e
)
.
readlines
():
for
l
in
open
(
args
.
dump_fil
e
)
.
readlines
():
m
=
r
.
match
(
l
)
if
m
!=
None
and
m
.
group
(
3
)
==
None
:
name
=
m
.
group
(
1
)
...
...
@@ -133,4 +145,4 @@ for l in open(profile.filename).readlines():
profile
.
add
(
name
,
prediction
,
count
,
hits
)
profile
.
dump
()
profile
.
dump
(
args
.
sorting
)
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