Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plot #375

Merged
merged 5 commits into from
Aug 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
/.vagrant
/index.lmdb
/index.redb
/ord.log
/target
49 changes: 49 additions & 0 deletions bin/graph
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#!/usr/bin/env python3

import re
from matplotlib.pyplot import *
from dataclasses import dataclass

@dataclass
class Block:
height: int
ranges: int
time: int
transactions: int

pat = re.compile(
'''Block (?P<height>[0-9]+).*with (?P<transactions>[0-9]+) transactions.*
.*Wrote (?P<ranges>[0-9]+) ordinal ranges in (?P<time>[0-9]+)ms'''
)

blocks = [
Block(**{k : int(v) for k, v in group.items()})
for group in [
match.groupdict() for match in pat.finditer(open('ord.log').read())
]
]

_, (a, b, c) = subplots(3)

a.set_xlabel('Height')
a.set_ylabel('Time')
a.plot(
[block.height for block in blocks],
[block.time for block in blocks],
)

b.set_xlabel('Ranges')
b.set_ylabel('Time')
b.scatter(
[block.ranges for block in blocks],
[block.time for block in blocks],
)

c.set_xlabel('Tx\'s in block')
c.set_ylabel('Time')
c.scatter(
[block.transactions for block in blocks],
[block.time for block in blocks],
)

show()
3 changes: 3 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,6 @@ update-modern-normalize:
curl \
https://raw.githubusercontent.com/sindresorhus/modern-normalize/main/modern-normalize.css \
> static/modern-normalize.css

graph:
./bin/graph