Skip to content

Instantly share code, notes, and snippets.

View mh-keshavarz's full-sized avatar

Mohammad hossein keshavarz mh-keshavarz

View GitHub Profile
@mh-keshavarz
mh-keshavarz / silk-profiler.py
Last active July 21, 2024 06:27
A function replacing silk middleware
from django.test.client import RequestFactory
from django.http import HttpResponse
from django.db import transaction, DatabaseError
from django.db.models.sql.compiler import SQLCompiler
from django.utils import timezone
from silk.collector import DataCollector
from silk.config import SilkyConfig
from silk.model_factory import RequestModelFactory, ResponseModelFactory
from silk.profiling.profiler import silk_meta_profiler