10K_children.py 635 B

123456789101112131415161718192021222324252627
  1. #!/usr/bin/env python
  2. import arrow
  3. import requests
  4. n = 10000
  5. # Generate 10,000 children of root node.
  6. requests.put('http://localhost:8000/ldp/pomegranate')
  7. start = arrow.utcnow()
  8. ckpt = start
  9. print('Inserting {} children.'.format(n))
  10. for i in range(1, n):
  11. requests.post('http://localhost:8000/ldp/pomegranate')
  12. if i % 100 == 0:
  13. now = arrow.utcnow()
  14. tdelta = now - ckpt
  15. ckpt = now
  16. print('Record: {}\tTime elapsed: {}'.format(i, tdelta))
  17. tdelta = arrow.utcnow() - start
  18. print('Total elapsed time: {}'.format(tdelta))
  19. print('Average time per resource: {}'.format(tdelta.total_seconds()/n))