Skip to content

Instantly share code, notes, and snippets.

View patx's full-sized avatar

Harrison Erd patx

View GitHub Profile
@patx
patx / benchmark.md
Last active December 25, 2025 23:34

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
#!/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