Skip to content
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
6 changes: 6 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# **Diagnosticism.Python** Changes

## 0.17.0 - 10th July 2026

* added `DOOMGram::to_mmm()` and `DOOMGram::to_nmmm()` — compact min/mean/max duration summaries using `nanoseconds_to_string()`;
* updated compatibility to Python 3.18;


## 0.16.0 - 27th June 2026

* added `nanoseconds_to_string()`;
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ d.log(sev.INFO, "hello")
### Python version compatibility

**Diagnosticism.Python** is intended to run on **Python 2.7** and **Python
3.8+**. GitHub Actions exercises **Python 2.7** and **Python 3.8–3.13**.
3.8+**. GitHub Actions exercises **Python 2.7** and **Python 3.8–3.14**.

| Requirement | Applies to |
| ----------- | ---------- |
Expand Down
2 changes: 1 addition & 1 deletion diagnosticism/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
__license__ = 'BSD-3-Clause'
__maintainer__ = 'Matt Wilson'
__status__ = 'Beta'
__version__ = '0.16.0'
__version__ = '0.17.0'

import sys

Expand Down
68 changes: 66 additions & 2 deletions diagnosticism/doomgram.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
# Purpose: Definition of the `DOOMGram` class.
#
# Created: 19th July 2025
# Updated: 27th August 2025
# Updated: 10th July 2026
#
# Author: Matthew Wilson
#
# Copyright (c) 2025, Matthew Wilson and Synesis Information Systems
# Copyright (c) 2025-2026, Matthew Wilson and Synesis Information Systems
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -39,6 +39,11 @@
from .internal import (
_perf_counter_ns,
)
from .time_format import (
_to_mmm,
_to_nmmm,
)
from .time_format.nanoseconds import nanoseconds_to_string

import math

Expand Down Expand Up @@ -306,6 +311,65 @@ def push_event_time_s(self, time_in_s):

self.push_event_time_ns(time_in_s * 1000000000) # 1,000,000,000

def to_mmm(self, *kwargs):

# _OVERFLOW = "OVERFLOW"

count = self._event_count

if count == 0:

return ''

# if self._has_overflowed {
# return _OVERFLOW;
# }

min_ns = self._min_event_time_ns
max_ns = self._max_event_time_ns

if count == 1 or min_ns == max_ns:

return nanoseconds_to_string(min_ns)
else:
mean_ns = int(self._total_event_time_ns / count)

return _to_mmm(
nanoseconds_to_string(min_ns),
nanoseconds_to_string(mean_ns),
nanoseconds_to_string(max_ns),
)

def to_nmmm(self, *kwargs):

# _OVERFLOW = "OVERFLOW"

count = self._event_count

if count == 0:

return '0:'

# if self._has_overflowed {
# return str(count) + ':' + _OVERFLOW;
# }

min_ns = self._min_event_time_ns
max_ns = self._max_event_time_ns

if count == 1 or min_ns == max_ns:

return str(count) + ':' + nanoseconds_to_string(min_ns)
else:
mean_ns = int(self._total_event_time_ns / count)

return _to_nmmm(
count,
nanoseconds_to_string(min_ns),
nanoseconds_to_string(mean_ns),
nanoseconds_to_string(max_ns),
)

def to_strip(self, **kwargs):
"""
Converts to string form according to given options
Expand Down
12 changes: 10 additions & 2 deletions diagnosticism/time_format/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,17 @@
import sys

if sys.version_info[0] >= 3:
from ._fmt_py3 import _fmt
from ._fmt_py3 import (
_fmt,
_to_mmm,
_to_nmmm,
)
else:
from ._fmt_py2 import _fmt
from ._fmt_py2 import (
_fmt,
_to_mmm,
_to_nmmm,
)


_SCALES = (
Expand Down
29 changes: 27 additions & 2 deletions diagnosticism/time_format/_fmt_py2.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Purpose: Python 2.7 implementation of `_fmt()`.
#
# Created: 24th August 2025
# Updated: 27th June 2026
# Updated: 10th July 2026
#
# Copyright (c) 2026-2027, Matthew Wilson and Synesis Information Systems
# Copyright (c) 2025-2026, Matthew Wilson and Synesis Information Systems
# All rights reserved.
#
# ######################################################################## #
Expand Down Expand Up @@ -39,4 +39,29 @@ def _fmt(
return "%s%s.%s%s" % (sign, whole, frac, suffix)


def _to_mmm(
min,
mean,
max,
):
"""
Formats min+mean+max.
"""

return "%s-%s-%s" % (min, mean, max)


def _to_nmmm(
count,
min,
mean,
max,
):
"""
Formats count+min+mean+max.
"""

return "%d:%s-%s-%s" % (count, min, mean, max)


# ############################## end of file ############################# #
29 changes: 27 additions & 2 deletions diagnosticism/time_format/_fmt_py3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# Purpose: Python 3 implementation of `_fmt()`.
#
# Created: 24th August 2025
# Updated: 27th June 2026
# Updated: 10th July 2026
#
# Copyright (c) 2026-2027, Matthew Wilson and Synesis Information Systems
# Copyright (c) 2025-2026, Matthew Wilson and Synesis Information Systems
# All rights reserved.
#
# ######################################################################## #
Expand Down Expand Up @@ -39,4 +39,29 @@ def _fmt(
return f"{sign}{whole}.{frac}{suffix}"


def _to_mmm(
min,
mean,
max,
):
"""
Formats min+mean+max.
"""

return f"{min}-{mean}-{max}"


def _to_nmmm(
count,
min,
mean,
max,
):
"""
Formats count+min+mean+max.
"""

return f"{count}:{min}-{mean}-{max}"


# ############################## end of file ############################# #
2 changes: 1 addition & 1 deletion diagnosticism/time_format/nanoseconds.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# Created: 24th August 2025
# Updated: 27th June 2026
#
# Copyright (c) 2026-2027, Matthew Wilson and Synesis Information Systems
# Copyright (c) 2025-2026, Matthew Wilson and Synesis Information Systems
# All rights reserved.
#
# ######################################################################## #
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

name='diagnosticism',
python_requires='>=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, !=3.6.*, !=3.7.*',
version='0.16.0',
version='0.17.0',

author='Matt Wilson',
author_email='matthew@synesis.com.au',
Expand All @@ -24,6 +24,7 @@
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Programming Language :: Python :: 3.13",
"Programming Language :: Python :: 3.14",
],
description='Basic diagnostic facilities, for Python',
keywords='Diagnostic Diagnostics Logging Trace Tracing Stopwatch',
Expand Down
Loading
Loading