Browse Source

added 3 test cases, Fortunes, Data updates and Plaintext.

AOYAMA Kazuharu 12 years ago
parent
commit
2ac5a79395

+ 4 - 1
treefrog/benchmark_config

@@ -6,7 +6,10 @@
       "json_url": "/json/json",
       "db_url": "/world/random",
       "query_url": "/world/queries/",
-      "port": 8800,
+      "fortune_url": "/fortune/index",
+      "update_url": "/world/updates/",
+      "plaintext_url": "/world/plain",
+      "port": 8080,
       "sort": 117
     }
   }]

+ 10 - 2
treefrog/config/application.ini

@@ -4,7 +4,7 @@
 [General]
 
 # Listens on the specified port.
-ListenPort=8800
+ListenPort=8080
 
 # Sets the codec used by 'QObject::tr()' and 'toLocal8Bit()' to the
 # QTextCodec for the specified encoding. See QTextCodec class reference.
@@ -24,6 +24,7 @@ Locale=
 
 # Specify the multiprocessing module, such as 'thread' or 'prefork'
 MultiProcessingModule=thread
+#MultiProcessingModule=hybrid
 
 # Specify the absolute or relative path of the temporary directory
 # for HTTP uploaded files. Uses system default if not specified.
@@ -49,7 +50,7 @@ SystemLogFile=log/treefrog.log
 # Specify a file path for SQL query log.
 # If it's empty or the line is commented out, output to SQL query log
 # is disabled.
-SqlQueryLogFile=log/query.log
+SqlQueryLogFile=
 
 # Determines whether the application aborts (to create a core dump
 # on Unix systems) or not when it output a fatal message by tFatal()
@@ -121,6 +122,13 @@ MPM.prefork.MinServers=5
 # Number of server processes which are kept spare
 MPM.prefork.SpareServers=5
 
+##
+## MPM Hybrid section
+##
+
+# Maximum number of server threads allowed to start in hybrid MPM
+MPM.hybrid.MaxServers=1024
+
 ##
 ## SystemLog settings
 ##

+ 7 - 7
treefrog/config/database.ini

@@ -21,17 +21,17 @@ DriverType=QMYSQL
 DatabaseName=hello_world
 HostName=localhost
 Port=
-UserName=root
-Password=secret
+UserName=benchmarkdbuser
+Password=benchmarkdbpass
 ConnectOptions=
 
 [test]
 DriverType=QMYSQL
-DatabaseName=
+DatabaseName=hello_world
 HostName=localhost
 Port=
-UserName=
-Password=
+UserName=benchmarkdbuser
+Password=benchmarkdbpass
 ConnectOptions=
 
 [product]
@@ -39,6 +39,6 @@ DriverType=QMYSQL
 DatabaseName=hello_world
 HostName=localhost
 Port=
-UserName=root
-Password=secret
+UserName=benchmarkdbuser
+Password=benchmarkdbpass
 ConnectOptions=

+ 22 - 2
treefrog/controllers/worldcontroller.cpp

@@ -13,6 +13,11 @@ void WorldController::index()
     render();
 }
 
+void WorldController::plain()
+{
+    renderText(QLatin1String("Hello, World!"));
+}
+
 void WorldController::show(const QString &pk)
 {
     World world = World::get(pk.toUInt());
@@ -26,8 +31,8 @@ void WorldController::queries(const QString &num)
     int d = num.toInt();
     for (int i = 0; i < d; ++i) {
         int id = Tf::random(9999) + 1;
-	World world = World::get(id);
-	worlds << world.toVariantMap();
+        World world = World::get(id);
+        worlds << world.toVariantMap();
     }
     setContentType("application/json");
     renderText(jsonEncode(worlds), false);
@@ -115,6 +120,21 @@ void WorldController::renderEdit(const QVariantMap &world)
     render("edit");
 }
 
+void WorldController::updates(const QString &num)
+{
+    QList<QVariantMap> worlds;
+    int d = num.toInt();
+    for (int i = 0; i < d; ++i) {
+        int id = Tf::random(9999) + 1;
+        World world = World::get(id);
+        world.setRandomnumber( Tf::random(9999) + 1 );
+        world.update();
+	worlds << world.toVariantMap();
+    }
+    setContentType("application/json");
+    renderText(jsonEncode(worlds), false);
+}
+
 void WorldController::remove(const QString &pk)
 {
     if (httpRequest().method() != Tf::Post) {

+ 2 - 0
treefrog/controllers/worldcontroller.h

@@ -15,6 +15,7 @@ public:
 
 public slots:
     void index();
+    void plain();
     void show(const QString &pk);
     void queries(const QString &num);
     void random();
@@ -22,6 +23,7 @@ public slots:
     void create();
     void edit(const QString &pk);
     void save(const QString &pk);
+    void updates(const QString &num);
     void remove(const QString &pk);
 
 private:

+ 2 - 1
treefrog/setup.py

@@ -18,7 +18,8 @@ def start(args):
   # 4. Start TreeFrog
   try:
     subprocess.check_call("qmake -r CONFIG+=release", shell=True, cwd="treefrog")
-    subprocess.check_call("make", shell=True, cwd="treefrog")
+    subprocess.check_call("make clean", shell=True, cwd="treefrog")
+    subprocess.check_call("make -j8", shell=True, cwd="treefrog")
     subprocess.check_call("rm -f log/*.log", shell=True, cwd="treefrog")
     subprocess.check_call("treefrog -d " + home + "/FrameworkBenchmarks/treefrog", shell=True)
     return 0

+ 10 - 22
treefrog/views/fortune/index.erb

@@ -2,34 +2,22 @@
 <%#include "fortune.h" %>
 <html>
 <head>
-  <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
-  <title><%= controller()->name() + ": " + controller()->activeAction() %></title>
+<title>Fortunes</title>
 </head>
 <body>
-
-<h1>Listing Fortune</h1>
-
-<%== linkTo("New entry", urla("entry")) %><br />
-<br />
-<table border="1" cellpadding="5" style="border: 1px #d0d0d0 solid; border-collapse: collapse;">
-  <tr>
-    <th>ID</th>
-    <th>Message</th>
-  </tr>
+<table>
+<tr>
+<th>id</th>
+<th>message</th>
+</tr>
 <% tfetch(QList<Fortune>, fortuneList); %>
 <% for (QListIterator<Fortune> it(fortuneList); it.hasNext(); ) {
      const Fortune &i = it.next(); %>
-  <tr>
-    <td><%= i.id() %></td>
-    <td><%= i.message() %></td>
-    <td>
-      <%== linkTo("Show", urla("show", i.id())) %>
-      <%== linkTo("Edit", urla("edit", i.id())) %>
-      <%== linkTo("Remove", urla("remove", i.id()), Tf::Post, "confirm('Are you sure?')") %>
-    </td>
-  </tr>
+<tr>
+<td><%= i.id() %></td>
+<td><%= i.message() %></td>
+</tr>
 <% } %>
 </table>
-
 </body>
 </html>