Skip to content

Commit

Permalink
Add graph recipe (ordinals#375)
Browse files Browse the repository at this point in the history
  • Loading branch information
terror committed Aug 24, 2022
1 parent 9339b21 commit 6caeb41
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 0 deletions.
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

0 comments on commit 6caeb41

Please sign in to comment.