Child: [ddf08c] (diff)

Download this file

sstress.py    37 lines (31 with data), 760 Bytes

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python
'''
sstress - an SMTP stress testing tool
'''
import smtplib
import threading
import time
C = 5
N = 1000
TOADDR = 'nobody@localhost'
SERVER = 'localhost'
PORT = 8825
SIZE = 10 * (2**10)
EMAIL_TEXT = 'X' * SIZE
def main():
threads = [ threading.Thread(target=stress) for x in xrange(C) ]
begin = time.time()
for t in threads:
t.start()
for t in threads:
t.join()
end = time.time()
elapsed = end - begin
print '%d requests completed in %f seconds' % (N, elapsed)
print '%f requests/second' % (N/elapsed)
def stress():
server = smtplib.SMTP(SERVER, PORT)
for x in xrange(N/C):
server.sendmail('sstress@localhost', TOADDR, EMAIL_TEXT)
if __name__ == '__main__':
main()