Skip to main content

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

Project description

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
    }
  }
}

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gadpytestprofiler-0.0.1.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gadpytestprofiler-0.0.1-py3-none-any.whl (18.6 kB view details)

Uploaded Python 3

File details

Details for the file gadpytestprofiler-0.0.1.tar.gz.

File metadata

  • Download URL: gadpytestprofiler-0.0.1.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for gadpytestprofiler-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9b4697048b90efe1b5dd6cd68206ff16a7b0fdbe8be1e88e81638fcb6f872cdc
MD5 1f3b27d1c36ba49b23979e253d10e161
BLAKE2b-256 4e12ddb0bfaddf719834b6b2603a4db2e1946cc7a1dd3a53b75f1d56b5443ba8

See more details on using hashes here.

File details

Details for the file gadpytestprofiler-0.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gadpytestprofiler-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03ba6838287983a3da3a09487b63345e22338008a8823f7b37fb85aa1efc5316
MD5 15855634d8c73b735e6ae7f365cd3f23
BLAKE2b-256 fdbcc2a3109343fdb3796d54dc5c6dc114676dd2093b099a1bcfdc3925c7fb97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page