Skip to content

Instantly share code, notes, and snippets.

@tomplex
Created April 9, 2017 00:58
Show Gist options
  • Save tomplex/68a8802c73cb791708a5de8f00327250 to your computer and use it in GitHub Desktop.
Save tomplex/68a8802c73cb791708a5de8f00327250 to your computer and use it in GitHub Desktop.
Test how long it takes to get x pages from investorhub
import requests
import time
import sys
def main():
base_url = 'http://investorshub.advfn.com/boards/read_msg.aspx?message_id={}'
times = []
program_start = time.time()
num_pages = int(sys.argv[1])
for post_id in range(120000000, 120000000 + num_pages):
try:
start = time.time()
r = requests.get(base_url.format(post_id))
except:
pass
finally:
times.append((time.time() - start))
program_stop = time.time()
program_length = program_stop - program_start
avg_time = sum(times) / float(len(times))
max_time = max(times)
min_time = min(times)
print("""Got {} pages in {} \n\t average time: {} \n\t min time: {} \n\t max time: {}""".format(num_pages,
program_length,
avg_time, min_time, max_time))
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment