Skip to content

Commit

Permalink
don't grab the big files so often, add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsw committed Feb 19, 2011
1 parent 71205ef commit 14d9bf5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
8 changes: 8 additions & 0 deletions torperf2-HOWTO
@@ -0,0 +1,8 @@
Add this to your crontab:

*/5 * * * * timeout -2 295 ~/torperf/torperf2.py 50kbfile
2,32 * * * * timeout -2 1795 ~/torperf/torperf2.py 1mbfile
8 * * * * timeout -2 3595 ~/torperf/torperf2.py 5mbfile

This will request various files and varying intervals and store the results
in ~/torperf/torperf2.log.
16 changes: 13 additions & 3 deletions torperf2.py 100644 → 100755
@@ -1,4 +1,5 @@
import socket, sys, time, subprocess, threading, signal, fcntl
#!/usr/bin/env python
import socket, sys, time, subprocess, threading, signal, fcntl, os
import TorCtl.TorCtl

LOGFILE = 'torperf2.log'
Expand All @@ -22,6 +23,11 @@
DataDir .tor
""" % (HOST, PORT, PORT+1)

def nukedir(dirname):
for fn in os.listdir(dirname):
os.unlink(dirname + os.path.sep + fn)
os.rmdir(dirname)

def start_tor():
global TORPROCESS
file('torrc', 'w').write(TORRC)
Expand Down Expand Up @@ -100,13 +106,17 @@ def main(host, port, fn, fh):
shared['torlock'].acquire()

grab_page(handler, HIDDEN + fn, 'hidden|%s|cold'%fn)
grab_page(handler, HIDDEN + fn, 'hidden|%s|warm'%fn)
if fn == '50kbfile':
grab_page(handler, HIDDEN + fn, 'hidden|%s|warm'%fn)
grab_page(handler, PUBLIC + fn, 'public|%s|cold'%fn)
grab_page(handler, HIDDEN + fn, 'hidden|%s|lukewarm'%fn)
if fn == '50kbfile':
grab_page(handler, HIDDEN + fn, 'hidden|%s|lukewarm'%fn)
handler.log('END_TOR')

if __name__ == "__main__":
try:
os.chdir(os.path.sep.join(sys.argv[0].split(os.path.sep)[:-1]))
nukedir('.tor')
fh = file(LOGFILE, 'a')
fcntl.lockf(fh, fcntl.LOCK_EX)
main(HOST, PORT, sys.argv[1], fh)
Expand Down

0 comments on commit 14d9bf5

Please sign in to comment.