Clean up test/helper_tools directory

This commit is contained in:
Aldo Cortesi 2018-04-07 09:54:37 +12:00
parent b663a224a3
commit 850c855495
5 changed files with 0 additions and 51323 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,23 +0,0 @@
import requests
import time
n = 100
url = "http://192.168.1.1/"
proxy = "http://192.168.1.115:8080/"
start = time.time()
for _ in range(n):
requests.get(url, allow_redirects=False, proxies=dict(http=proxy))
print(".", end="")
t_mitmproxy = time.time() - start
print("\r\nTotal time with mitmproxy: {}".format(t_mitmproxy))
start = time.time()
for _ in range(n):
requests.get(url, allow_redirects=False)
print(".", end="")
t_without = time.time() - start
print("\r\nTotal time without mitmproxy: {}".format(t_without))

View File

@ -1,56 +0,0 @@
# Profile mitmdump with apachebench and
# yappi (https://code.google.com/p/yappi/)
#
# Requirements:
# - Apache Bench "ab" binary
# - pip install click yappi
from mitmproxy.main import mitmdump
from os import system
from threading import Thread
import time
import yappi
import click
class ApacheBenchThread(Thread):
def __init__(self, concurrency):
self.concurrency = concurrency
super().__init__()
def run(self):
time.sleep(2)
system(
"ab -n 1024 -c {} -X 127.0.0.1:8080 http://example.com/".format(self.concurrency))
@click.command()
@click.option('--profiler', default="none", type=click.Choice(['none', 'yappi']))
@click.option('--clock-type', default="cpu", type=click.Choice(['wall', 'cpu']))
@click.option('--concurrency', default=1, type=click.INT)
def main(profiler, clock_type, concurrency):
outfile = "callgrind.mitmdump-{}-c{}".format(clock_type, concurrency)
a = ApacheBenchThread(concurrency)
a.start()
if profiler == "yappi":
yappi.set_clock_type(clock_type)
yappi.start(addons=True)
print("Start mitmdump...")
mitmdump(["-k", "-q", "-S", "1024example"])
print("mitmdump stopped.")
print("Save profile information...")
if profiler == "yappi":
yappi.stop()
stats = yappi.get_func_stats()
stats.save(outfile, type='callgrind')
print("Done.")
if __name__ == '__main__':
main()

View File

@ -1,9 +0,0 @@
#!/bin/bash
# Generate a test pattern with pathoc
PATHOD=localhost:9999
pathoc -s -c $PATHOD localhost:8080 "get:'/p/200:p0,1:b@2048b':b@2048b"
pathoc -s -c $PATHOD localhost:8080 "get:'/p/300:p0,1:b@2048b':b@2048b"
pathoc -s -c $PATHOD localhost:8080 "get:'/p/400:p0,1:b@2048b':b@2048b"
pathoc -s -c $PATHOD localhost:8080 "get:'/p/500:p0,1:b@2048b':b@2048b"
pathoc -s -c $PATHOD localhost:8080 "get:'/p/600:p0,1:b@2048b':b@2048b"

View File

@ -1,34 +0,0 @@
import typing
from unittest import mock
from mitmproxy import proxy, options
from mitmproxy.tools import dump, console, web
def print_typehints(opts):
for name, option in sorted(opts.items()):
print(
# For Python 3.6, we can just use "{}: {}".
"{}: {} = None".format(
name,
{
int: "int",
str: "str",
bool: "bool",
typing.Optional[str]: "Optional[str]",
typing.Sequence[str]: "Sequence[str]"
}[option.typespec]
)
)
if __name__ == "__main__":
opts = options.Options()
server = proxy.server.DummyServer(None)
# initialize with all three tools here to capture tool-specific options defined in addons.
dump.DumpMaster(opts, server)
with mock.patch("sys.stdout.isatty", lambda: True):
console.master.ConsoleMaster(opts, server)
web.master.WebMaster(opts, server)
print_typehints(opts)