Browse Source

update test for bottle

Patrick Falls 12 years ago
parent
commit
125864a105
2 changed files with 18 additions and 0 deletions
  1. 17 0
      bottle/app.py
  2. 1 0
      bottle/benchmark_config

+ 17 - 0
bottle/app.py

@@ -68,5 +68,22 @@ def get_random_world_single_raw():
   connection.close()
   return ujson.dumps(worlds)
 
[email protected]("/update")
+def update_worlds(db):
+  num_queries = int(request.query.queries or '1')
+  if num_queries < 1:
+    num_queries = 1
+  else if num_queries > 500:
+    num_queries = 500
+
+  worlds = []
+  for i in range(num_queries):
+    wid = randint(1, 10000)
+    world = db.query(World).get(wid)
+    world.randomNumber = randint(1, 10000)
+    db.commit()
+    worlds.append(world.serialize)
+  return ujson.dumps(worlds)
+
 if __name__ == "__main__":
     app.run()

+ 1 - 0
bottle/benchmark_config

@@ -6,6 +6,7 @@
       "json_url": "/json",
       "db_url": "/dbs",
       "query_url": "/db?queries=",
+      "update_url": "/update?queries=",
       "port": 8080,
       "sort": 88
     },