Permalink
Browse files

don't grab the big files so often, add docs

  • Loading branch information...
1 parent 71205ef commit 14d9bf5c014df2c8b55aebfd886498950618b6c3 @aaronsw committed Feb 19, 2011
Showing with 21 additions and 3 deletions.
  1. +8 −0 torperf2-HOWTO
  2. +13 −3 torperf2.py
View
8 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.
View
16 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'
@@ -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)
@@ -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)

0 comments on commit 14d9bf5

Please sign in to comment.