Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
G
ghc-utils
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
7
Issues
7
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
3
Merge Requests
3
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ben Gamari
ghc-utils
Commits
7ae9ceaf
Commit
7ae9ceaf
authored
Jan 11, 2021
by
Ben Gamari
🐢
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ghc_timings: Use pandas
parent
f9207038
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
5 deletions
+12
-5
default.nix
default.nix
+2
-0
ghc_timings.py
ghc_timings.py
+10
-5
No files found.
default.nix
View file @
7ae9ceaf
...
...
@@ -38,6 +38,8 @@ let
--prefix PATH :
${
python3
.
withPackages
(
pkgs
:
with
pkgs
;
[
matplotlib
pandas
tabulate
])
}
/bin
makeWrapper
${
./sample_proc.py
}
$out/bin/sample-proc \
--prefix PATH :
${
python3
.
withPackages
(
pkgs
:
with
pkgs
;
[
matplotlib
pandas
tabulate
])
}
/bin
makeWrapper
${
./ghc_timings.py
}
$out/bin/ghc-timings \
--prefix PATH :
${
python3
.
withPackages
(
pkgs
:
with
pkgs
;
[
matplotlib
pandas
tabulate
])
}
/bin
''
;
};
gdb
=
import
./gdb
{
inherit
nixpkgs
;
};
...
...
ghc_timings.py
View file @
7ae9ceaf
...
...
@@ -4,6 +4,7 @@
import
re
import
sys
import
typing
import
pandas
as
pd
from
typing
import
Iterator
class
Timing
(
typing
.
NamedTuple
):
...
...
@@ -12,7 +13,7 @@ class Timing(typing.NamedTuple):
time
:
float
allocd
:
float
def
parse_timings
(
s
:
str
)
->
Iterator
[
Timing
]:
def
parse_timings
_raw
(
s
:
str
)
->
Iterator
[
Timing
]:
for
m
in
re
.
finditer
(
r'!!! ([\w \d]+) \[([\w\d_\.]+)\]: finished in (\d+\.\d+) milliseconds, allocated (\d+\.\d+) megabytes'
,
s
):
phase
=
m
.
group
(
1
)
module
=
m
.
group
(
2
)
...
...
@@ -20,12 +21,16 @@ def parse_timings(s: str) -> Iterator[Timing]:
allocd
=
float
(
m
.
group
(
4
))
yield
Timing
(
phase
,
module
,
time
,
allocd
)
def
parse_timings
(
s
:
str
)
->
pd
.
DataFrame
:
xs
=
list
(
parse_timings_raw
(
s
))
df
=
pd
.
DataFrame
(
xs
,
columns
=
[
'phase'
,
'module'
,
'time'
,
'allocd'
])
df
[
'n'
]
=
df
.
index
df
.
sort_values
(
by
=
[
'module'
,
'n'
],
inplace
=
True
)
return
df
.
drop
(
columns
=
'n'
)
def
main
()
->
None
:
s
=
sys
.
stdin
.
read
()
print
(
'| module | phase | time (ms) | alloc (MB) |'
)
print
(
'| ------ | ----- | --------- | ---------- |'
)
for
t
in
parse_timings
(
s
):
print
(
'| {module} | {phase} | {time} | {allocd} |'
.
format
(
**
t
))
print
(
parse_timings
(
s
).
to_markdown
())
if
__name__
==
'__main__'
:
main
()
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