Skip to content

Instantly share code, notes, and snippets.

@patx
patx / benchmark_review.md
Last active July 8, 2025 01:13
Latest benchmarks for new MicroPie release (v0.17)

Benchmarking Python Web Frameworks: Blacksheep, Starlette, MicroPie, Quart, FastAPI

I created minimal apps for each framework, all returning {"Hello": "World"} as JSON. They ran on Uvicorn with a single worker for baseline performance. Tests hit http://127.0.0.1:8000 with wrk (15s, 4 threads, 64 connections).

Blacksheep

from blacksheep import Application, get, json

app = Application()
@patx
patx / benchmark998.md
Created May 30, 2025 00:24
benchmark for micropie v0.9.9.8

Benchmarks for MicroPie v0.9.9.8

Extremely simple comparisons between fast ASGI frameworks. Each framework used uvicorn as the server using uvicorn file:app --workers 4. Tests were performed on a Dell XPS 13 with 16GB of RAM.

MicroPie

from MicroPie import App

class Root(App):

    async def index(self):
@patx
patx / benchmark.md
Last active February 5, 2025 00:41

ASGI Framework Performance Benchmark

Introduction

This benchmark compares the performance of various ASGI web frameworks when serving a simple "Hello, World!" response under high concurrency. The test setup includes running each framework with Uvicorn (4 workers) where applicable and using wrk to simulate concurrent requests.

Test Setup

Each framework was tested using the following command:

wrk -t4 -c1000 -d30s http://127.0.0.1:8000/

MicroPie vs FastAPI Benchmarks (with wrk)

FastAPI

The code used:

from fastapi import FastAPI
from typing import Optional
@patx
patx / kenobidb.py
Created January 17, 2025 00:36
Dev version of kenobi (https://github.com/patx/kenobi)
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
KenobiDB is a small document-based DB, supporting simple usage including
insertion, removal, and basic search.
Written by Harrison Erd (https://patx.github.io/)
https://patx.github.io/kenobi/
"""
# Copyright Harrison Erd
#
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright 2019 Harrison Erd
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
@patx
patx / pickledb_async_AsyncPickleDB.py
Last active January 10, 2025 04:24
Async scripts to help pickleDB Use with caution these are developmental. Please post suggestions: https://github.com/patx/pickledb/issues
import threading
from concurrent.futures import ThreadPoolExecutor
class AsyncPickleDB:
def __init__(self, db_instance, max_workers=5):
"""
Initialize the AsyncPickleDB with threading and thread pool executor.
Args:
db_instance (PickleDB): An instance of PickleDB to wrap.
Test Results Summary
JsonDB
1,000,000 records:
Insertion: 1.57s
Retrieval: 0.73s
Dump: 1.24s
Total: 3.55s
10,000,000 records:
@patx
patx / blackjack.py
Created November 18, 2018 02:05
simple blackjack game in python
#!/usr/bin/env python3
# Harrison Erd
# Nov 14, 2018
# blackjack game
from os import system, name
from random import choice, choices, seed