Browse Source

Merge branch 'hhvm_bench8feedback' of https://github.com/nareshv/FrameworkBenchmarks into PR666

Conflicts:
	hhvm/db.php
	hhvm/fortunes.php
	hhvm/json.php
	hhvm/plaintext.php
	hhvm/queries.php
	hhvm/updates.php
Mike Smith 11 years ago
parent
commit
e3f9726680
10 changed files with 66 additions and 36 deletions
  1. 3 2
      hhvm/db.php
  2. 2 0
      hhvm/deploy/config-debug.hdf
  3. 2 0
      hhvm/deploy/config.hdf
  4. 3 2
      hhvm/fortunes.php
  5. 5 3
      hhvm/json.php
  6. 22 7
      hhvm/once.php.inc
  7. 5 2
      hhvm/plaintext.php
  8. 10 9
      hhvm/queries.php
  9. 4 2
      hhvm/setup.py
  10. 10 9
      hhvm/updates.php

+ 3 - 2
hhvm/db.php

@@ -6,7 +6,8 @@
 require_once dirname(__FILE__).'/once.php.inc';
 
 function main() {
-  $b = new Benchmark();
-  $b->bench_db();
+    $b = new Benchmark();
+    $b->bench_db();
 }
+
 main();

+ 2 - 0
hhvm/deploy/config-debug.hdf

@@ -12,8 +12,10 @@ Server {
 
 # Enable debug logging
 Log {
+  UseLogFile = true
   UseSyslog = false
   Level = Verbose
+  File = /tmp/FrameworkBenchmarks/hhvm/error.log
 }
 
 # Enable jit for production mode

+ 2 - 0
hhvm/deploy/config.hdf

@@ -12,8 +12,10 @@ Server {
 
 # Disable logging completely
 Log {
+  UseLogFile = false
   UseSyslog = false
   Level = Error
+  File = /tmp/FrameworkBenchmarks/hhvm/error.log
 }
 
 # Enable jit for production mode

+ 3 - 2
hhvm/fortunes.php

@@ -6,7 +6,8 @@
 require_once dirname(__FILE__).'/once.php.inc';
 
 function main() {
-  $b = new Benchmark();
-  $b->bench_fortunes();
+    $b = new Benchmark();
+    $b->bench_fortunes();
 }
+
 main();

+ 5 - 3
hhvm/json.php

@@ -3,9 +3,11 @@
 // 1. JSON Test
 //
 
+require_once dirname(__FILE__).'/once.php.inc';
+
 function main() {
-  $data = json_encode(array('message' => 'Hello, World!'));
-  header('Content-Type: application/json');
-  echo $data;
+    $b = new Benchmark();
+    $b->bench_json();
 }
+
 main();

+ 22 - 7
hhvm/once.php.inc

@@ -3,12 +3,27 @@
 class Benchmark {
     var $pdo;
 
-    public function setup_db()
+    public function setup_db($need_utf8 = true)
     {
-        $this->pdo = new PDO('mysql:host=localhost;dbname=hello_world', 'benchmarkdbuser', 'benchmarkdbpass', array(
-            PDO::ATTR_PERSISTENT => true,
-            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"
-        ));
+        $attrs     = array(PDO::ATTR_PERSISTENT => true);
+        // hhvm doesn't support charset=utf8 in the DSN yet
+        // See https://github.com/facebook/hhvm/issues/1309
+        if ($need_utf8) {
+            $attrs[PDO::MYSQL_ATTR_INIT_COMMAND] = "SET NAMES utf8";
+        }
+        $this->pdo = new PDO('mysql:host=localhost;dbname=hello_world', 'benchmarkdbuser', 'benchmarkdbpass', $attrs);
+    }
+
+    public function bench_json()
+    {
+        header('Content-Type: application/json');
+        echo json_encode(array('message' => 'Hello, World!'));
+    }
+
+    public function bench_plaintext()
+    {
+        header('Content-Type: text/plain; charset=utf-8');
+        echo 'Hello, World!';
     }
 
     public function bench_db()
@@ -121,9 +136,9 @@ class Benchmark {
 <th>message</th>
 </tr>
 EOM;
-        foreach ( $arr as $id => &$fortune ) {
+        foreach ( $arr as $id => $fortune ) {
             echo '<tr>';
-            echo '<td>'.htmlspecialchars($id, ENT_QUOTES, 'utf-8').'</td>';
+            echo '<td>'.$id.'</td>';
             echo '<td>'.htmlspecialchars($fortune, ENT_QUOTES, 'utf-8').'</td>';
             echo '</tr>';
         }

+ 5 - 2
hhvm/plaintext.php

@@ -3,8 +3,11 @@
 // 6. Plaintext Test
 //
 
+require_once dirname(__FILE__).'/once.php.inc';
+
 function main() {
-  header('Content-Type: text/plain; charset=utf-8');
-  echo 'Hello, World!';
+    $b = new Benchmark();
+    $b->bench_plaintext();
 }
+
 main();

+ 10 - 9
hhvm/queries.php

@@ -6,16 +6,17 @@
 require_once dirname(__FILE__).'/once.php.inc';
 
 function main() {
-  // Read number of queries to run from URL parameter
-  $query_count = 1;
-  if (!empty($_GET['queries'])) {
-    $query_count = intval($_GET['queries']);
-  }
+    // Read number of queries to run from URL parameter
+    $query_count = 1;
+    if (!empty($_GET['queries'])) {
+      $query_count = intval($_GET['queries']);
+    }
 
-  // Fix the queries limits
-  $query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
+    // Fix the queries limits
+    $query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
 
-  $b = new Benchmark();
-  $b->bench_queries($query_count);
+    $b = new Benchmark();
+    $b->bench_queries($query_count);
 }
+
 main();

+ 4 - 2
hhvm/setup.py

@@ -7,10 +7,12 @@ from os.path import expanduser
 home = expanduser("~")
 
 def start(args, logfile, errfile):
-  setup_util.replace_text("hhvm/once.php.inc", "host=.*;", "host=" + args.database_host + ";")
+  setup_util.replace_text("hhvm/once.php.inc", "host=localhost;", "host=" + args.database_host + ";")
   setup_util.replace_text("hhvm/deploy/config.hdf", "SourceRoot = .*\/FrameworkBenchmarks", "SourceRoot = " + home + "/FrameworkBenchmarks")
   setup_util.replace_text("hhvm/deploy/config.hdf", "Path = .*\/.hhvm.hhbc", "Path = " + home + "/FrameworkBenchmarks/hhvm/.hhvm.bbhc")
-  setup_util.replace_text("hhvm/deploy/config.hdf", "PidFile = .*\/hhvm.pid", "Path = " + home + "/FrameworkBenchmarks/hhvm/hhvm.pid")
+  setup_util.replace_text("hhvm/deploy/config.hdf", "PidFile = .*\/hhvm.pid", "PidFile = " + home + "/FrameworkBenchmarks/hhvm/hhvm.pid")
+  setup_util.replace_text("hhvm/deploy/config.hdf", "File = .*\/error.log", "File = " + home + "/FrameworkBenchmarks/hhvm/error.log")
+
 
   try:
     if os.name == 'nt':

+ 10 - 9
hhvm/updates.php

@@ -6,16 +6,17 @@
 require_once dirname(__FILE__).'/once.php.inc';
 
 function main() {
-  // Read number of queries to run from URL parameter
-  $query_count = 1;
-  if (!empty($_GET['queries'])) {
-    $query_count = intval($_GET['queries']);
-  }
+    // Read number of queries to run from URL parameter
+    $query_count = 1;
+    if (!empty($_GET['queries'])) {
+      $query_count = intval($_GET['queries']);
+    }
 
-  // Fix the queries limits
-  $query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
+    // Fix the queries limits
+    $query_count = $query_count < 1 ? 1 : ($query_count > 500 ? 500 : $query_count);
 
-  $b = new Benchmark();
-  $b->bench_updates($query_count);
+    $b = new Benchmark();
+    $b->bench_updates($query_count);
 }
+
 main();