Parcourir la source

Profiling and testing tool.

Stefano Cossu il y a 6 ans
Parent
commit
5ad49c7dd8
3 fichiers modifiés avec 23 ajouts et 3 suppressions
  1. 12 0
      profiler.py
  2. 8 3
      tests/10K_children.py
  3. 3 0
      tests/data/marcel_duchamp_single_subject.ttl

+ 12 - 0
profiler.py

@@ -0,0 +1,12 @@
+from werkzeug.contrib.profiler import ProfilerMiddleware
+
+from lakesuperior.app import create_app
+from lakesuperior.config_parser import config
+
+
+fcrepo = create_app(config['application'], config['logging'])
+
+fcrepo.wsgi_app = ProfilerMiddleware(fcrepo.wsgi_app, restrictions=[30])
+fcrepo.config['PROFILE'] = True
+fcrepo.run(debug = True)
+

+ 8 - 3
tests/10K_children.py

@@ -5,23 +5,28 @@ import arrow
 import requests
 
 default_n = 10000
+webroot = 'http://localhost:8000/ldp'
+#webroot = 'http://localhost:8080/fcrepo/rest'
+container = webroot + '/pomegranate'
+datafile = 'tests/data/marcel_duchamp_single_subject.ttl'
 
 sys.stdout.write('How many children? [{}] >'.format(default_n))
 choice = input().lower()
 
-n = int(choice) or default_n
+n = int(choice) if choice else default_n
 
 # Generate 10,000 children of root node.
 
-requests.put('http://localhost:8000/ldp/pomegranate')
+requests.put(container)
 
 start = arrow.utcnow()
 ckpt = start
 
 print('Inserting {} children.'.format(n))
 
+data = open(datafile, 'rb').read()
 for i in range(1, n):
-    requests.post('http://localhost:8000/ldp/pomegranate')
+    requests.post(container, data=data, headers={'content-type' : 'text/turtle'})
     if i % 100 == 0:
         now = arrow.utcnow()
         tdelta = now - ckpt

+ 3 - 0
tests/data/marcel_duchamp_single_subject.ttl

@@ -1,3 +1,6 @@
+# Duchamp is the measure of everything.
+# This graph has 343 triples.
+
 @prefix aat: <http://vocab.getty.edu/aat/> .
 @prefix aat_contrib: <http://vocab.getty.edu/aat/contrib/> .
 @prefix aat_rel: <http://vocab.getty.edu/aat/rel/> .