Skip to content

Commit

Permalink
bugfix for cache hit ratio calculation (d'oh)
Browse files Browse the repository at this point in the history
  • Loading branch information
vyruss committed Aug 19, 2023
1 parent 645534a commit 6560434
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 10 deletions.
Empty file added pg_statviz--0.3--0.4.sql
Empty file.
2 changes: 1 addition & 1 deletion pg_statviz.control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# pg_statviz
comment = 'stats visualization and time series analysis'
default_version = '0.3'
default_version = '0.4'
schema = pgstatviz
relocatable = false
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[project]
name = "pg_statviz"
version = "0.1"
version = "0.4"
description = "A minimalist extension and utility pair for time series analysis and visualization of PostgreSQL internal statistics."
readme = "README.md"
requires-python = ">=3.7"
requires-python = ">=3.9"
license = {file = "LICENSE"}
keywords = ["open-source", "postgres", "opensource", "database", "dataviz", "time-series", "postgresql", "data-visualization", "database-management", "database-administration", "performance-analysis", "postgresql-database", "postgresql-extension", "time-series-analysis"]
authors = [{name = "Jimmy Angelakos", email = "[email protected]"}]
classifiers = ["Development Status :: 3 - Alpha",
classifiers = ["Development Status :: 4 - Beta",
"License :: OSI Approved :: PostgreSQL License",
"Programming Language :: Python :: 3",]
dependencies = ["argh", "contourpy", "cycler", "fonttools", "kiwisolver", "matplotlib", "numpy", "packaging", "Pillow", "psycopg2", "pyparsing", "python-dateutil", "six"]
Expand Down
6 changes: 4 additions & 2 deletions src/pg_statviz/libs/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ def setup():
fnt.fontManager.addfont(f)
plt.rcParams['font.family'] = 'Noto Sans'
plt.rcParams['font.size'] = 12
base_image_path=importlib.resources.files("pg_statviz.libs").joinpath("pg_statviz.png")
base_image_path = importlib.resources.files("pg_statviz.libs")\
.joinpath("pg_statviz.png")
im = plt.imread(str(base_image_path))
height = im.shape[0]
fig = plt.figure(figsize=(19.2, 10.8))
Expand All @@ -31,7 +32,8 @@ def setup():
def setupdouble():
plt = setup()[0]
fig, (splt1, splt2) = plt.subplots(2, figsize=(19.2, 10.8))
base_image_path=importlib.resources.files("pg_statviz.libs").joinpath("pg_statviz.png")
base_image_path = importlib.resources.files("pg_statviz.libs")\
.joinpath("pg_statviz.png")
im = plt.imread(str(base_image_path))
height = im.shape[0]
fig.figimage(im, 5, (fig.bbox.ymax - height - 6), zorder=3)
Expand Down
5 changes: 2 additions & 3 deletions src/pg_statviz/modules/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,8 @@ def cache(dbname=getpass.getuser(), host="/var/run/postgresql", port="5432",
raise SystemExit("No pg_statviz snapshots found in this database")

tstamps = [t['snapshot_tstamp'] for t in data]
ratio = [round(100 - (int(d['blks_read'])
/ (int(d['blks_hit']) if d['blks_hit'] != 0 else 1)
* 100), 2)
ratio = [round(int(d['blks_hit'])
/ int(d['blks_read']) + int(d['blks_hit']) * 100, 2)
for d in data]

# Plot cache hit ratio
Expand Down
2 changes: 1 addition & 1 deletion src/pg_statviz/pg_statviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
__author__ = "Jimmy Angelakos"
__copyright__ = "Copyright (c) 2023 Jimmy Angelakos"
__license__ = "PostgreSQL License"
__version__ = "0.3"
__version__ = "0.4"

import sys
from argh import ArghParser
Expand Down

0 comments on commit 6560434

Please sign in to comment.