Skip to main content

logo

A profiler for benchmarking queries, functions, and I/O/network performance, with pydantic outputs.


Installation

pip install gadpytestprofiler

Usage

import pytest
import asyncio
import time

from gadpytestprofiler import SqlalchemyProfiler, FunctionProfiler, AsyncFunctionProfiler


def timesleep():
    time.sleep(1)


async def aiotimesleep():
    await asyncio.sleep(1)


@pytest.mark.asyncio
async def test_query_performance(session):
    query = select(Dummy)

    _, results = await SqlalchemyProfiler(session, query, runs=1).analyze()
    print(results.json())

    _, results = FunctionProfiler(timesleep).analyze()
    print(results.json())

    _, results = await AsyncFunctionProfiler(aiotimesleep).analyze()
    print(results.json())

SqlalchemyProfiler

{
  "query": {
    "sql": {
      "execute": {
        "mean": 0.02488902601180598,
        "median": 0.02488902601180598,
        "stdev": 0,
        "min": 0.02488902601180598,
        "max": 0.02488902601180598
      },
      "fetch": {
        "mean": 0.027863386989338323,
        "median": 0.027863386989338323,
        "stdev": 0,
        "min": 0.027863386989338323,
        "max": 0.027863386989338323
      },
      "scalar": {
        "mean": 0.0004310549993533641,
        "median": 0.0004310549993533641,
        "stdev": 0,
        "min": 0.0004310549993533641,
        "max": 0.0004310549993533641
      }
    },
    "orm": {
      "execute": {
        "mean": 0.8350658340204973,
        "median": 0.8350658340204973,
        "stdev": 0,
        "min": 0.8350658340204973,
        "max": 0.8350658340204973
      },
      "fetch": {
        "mean": 0.05669003300135955,
        "median": 0.05669003300135955,
        "stdev": 0,
        "min": 0.05669003300135955,
        "max": 0.05669003300135955
      },
      "scalar": {
        "mean": 0.0001957119966391474,
        "median": 0.0001957119966391474,
        "stdev": 0,
        "min": 0.0001957119966391474,
        "max": 0.0001957119966391474
      }
    },
    "explains": [
      {
        "plan": {
          "type": "Seq Scan",
          "name": "dummy",
          "alias": "dummy",
          "startup": 0,
          "total": 168.32,
          "plan_rows": 10432,
          "plan_width": 22,
          "actual_rows": 10000,
          "actual_loops": 1,
          "actual_startup_time": 0.004,
          "actual_total_time": 0.564,
          "buffers": null,
          "plans": [],
          "filter": null,
          "index": null,
          "join": null
        },
        "planning": 0.139,
        "execution": 0.827
      }
    ]
  },
  "allocation": {
    "current": 14279120,
    "peak": 15467940
  },
  "execution": {
    "cpu": {
      "time": 27.66541111
    },
    "wall": {
      "time": 6.109025365000001
    },
    "ratio": 4.528612905832975
  },
  "garbage": {
    "collected": 1,
    "uncollectable": 9
  },
  "network": {
    "bytes": {
      "sent": 1210304,
      "received": 5687195
    },
    "packets": {
      "sent": 1375,
      "received": 2179
    }
  },
  "io": {
    "time": {
      "read": 0,
      "write": 162,
      "busy": 17
    },
    "bytes": {
      "read": 0,
      "write": 913408
    }
  }
}

Metadata

Release files for gadpytestprofiler 0.0.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gadpytestprofiler 0.0.1
File Size Uploaded
gadpytestprofiler-0.0.1.tar.gz 10.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gadpytestprofiler 0.0.1
File Interpreter ABI Platform
gadpytestprofiler-0.0.1-py3-none-any.whl Python 3 none any Details

Total release size: 29.0 kB

Release files / gadpytestprofiler-0.0.1.tar.gz

Download URL gadpytestprofiler-0.0.1.tar.gz
Size 10.4 kB
Tags Source
SHA-256 checksum
How to use checksums
9b4697048b90efe1b5dd6cd68206ff16a7b0fdbe8be1e88e81638fcb6f872cdc
BLAKE2b-256 checksum
How to use checksums
4e12ddb0bfaddf719834b6b2603a4db2e1946cc7a1dd3a53b75f1d56b5443ba8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release files / gadpytestprofiler-0.0.1-py3-none-any.whl

Download URL gadpytestprofiler-0.0.1-py3-none-any.whl
Size 18.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
03ba6838287983a3da3a09487b63345e22338008a8823f7b37fb85aa1efc5316
BLAKE2b-256 checksum
How to use checksums
fdbcc2a3109343fdb3796d54dc5c6dc114676dd2093b099a1bcfdc3925c7fb97
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.0.1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page