Skip to content

Commit

Permalink
Added some benchmarking 💪
Browse files Browse the repository at this point in the history
  • Loading branch information
lockie committed Aug 21, 2017
1 parent 111fa22 commit b4077b2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ data/
__pycache__
.git
.gitignore
core
urls.txt
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,5 @@ ENV/
####

data/
core
urls.txt
12 changes: 12 additions & 0 deletions siegerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
verbose = false
gmethod = GET
logfile = /tmp/siege.log
#connection = keep-alive
limit = 1000
concurrent = 250
time = 7M
file = urls.txt
internet = false
timeout = 2
benchmark = true
failures = 100000
31 changes: 31 additions & 0 deletions urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#!/usr/bin/env python3

import sys


def main(argv):
if len(argv) != 3:
print('Usage: ' + argv[0] + ' <ammo file> <urls.txt file>')
return 1

with open(argv[1], 'rb') as ammofile:
ammo = ammofile.read().decode('utf8')

with open(argv[2], 'a') as urls:
prevline = None
post = None
for line in ammo.split('\n'):
if line.startswith('GET'):
urls.write(
'http://localhost' + line.split()[1] + '\n')
if line.startswith('POST'):
post = line.split()[1]
if prevline == '\r' and post:
urls.write(
'http://localhost' + post + ' POST ' + line + '\n')
post = None
prevline = line
return 0

if __name__ == '__main__':
sys.exit(main(sys.argv))

0 comments on commit b4077b2

Please sign in to comment.