Browse Source

verify Re-enabling elli and trying to fix db test

Mike Smith 11 years ago
parent
commit
db6cdbe5a7
2 changed files with 16 additions and 3 deletions
  1. 2 3
      elli/benchmark_config
  2. 14 0
      elli/src/elli_bench_cb.erl

+ 2 - 3
elli/benchmark_config

@@ -5,7 +5,7 @@
       "setup_file": "setup_erlang",
       "json_url": "/json",
       "db_url": "/db",
-      "query_url": "/db?queries=",
+      "query_url": "/query?queries=",
       "port": 8080,
       "approach": "Realistic",
       "classification": "Platform",
@@ -19,7 +19,6 @@
       "database_os": "Linux",
       "display_name": "elli",
       "notes": "",
-      "versus": "",
-      "skip": "true"
+      "versus": ""
   }}]
 }

+ 14 - 0
elli/src/elli_bench_cb.erl

@@ -25,6 +25,20 @@ handle('GET',[<<"db">>], Req) ->
 			        {result_packet, _, _, [[ID, Rand]], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
 			Res
 		end,
+    {ok, [{<<"Content-Type">>, <<"application/json">>}], jiffy:encode(lists:nth(1,JSON))};
+
+handle('GET',[<<"query">>], Req) ->
+        random:seed(erlang:now()),
+        JSON = case elli_request:get_arg(<<"queries">>, Req) of
+        undefined ->
+            {result_packet, _, _, [[ID, Rand]], _} = emysql:execute(test_pool, db_stmt, [random:uniform(10000)]),
+            [{[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]}];
+        N ->
+            I = list_to_integer(binary_to_list(N)),
+            Res = [ {[{<<"id">>, ID}, {<<"randomNumber">>, Rand}]} || 
+                    {result_packet, _, _, [[ID, Rand]], _} <- [emysql:execute(test_pool, db_stmt, [random:uniform(10000)]) || _ <- lists:seq(1, I) ]],
+            Res
+        end,
     {ok, [{<<"Content-Type">>, <<"application/json">>}], jiffy:encode(JSON)};
 
 handle(_, _, _Req) ->