Browse Source

Merge remote-tracking branch 'upstream/master'

Lucian Pacurar 11 years ago
parent
commit
896c41cdf1

+ 1 - 1
grizzly-bm/benchmark_config

@@ -18,7 +18,7 @@
       "database_os": "Linux",
       "display_name": "grizzly",
       "notes": "",
-      "versus": "servlet"
+      "versus": ""
     }
   }]
 }

+ 14 - 16
grizzly-bm/src/main/java/org/glassfish/grizzly/bm/JsonHttpHandler.java

@@ -2,6 +2,7 @@ package org.glassfish.grizzly.bm;
 
 import com.fasterxml.jackson.core.JsonFactory;
 import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.databind.*;
 import java.io.IOException;
 import java.util.concurrent.ExecutorService;
 import org.glassfish.grizzly.http.server.HttpHandler;
@@ -14,7 +15,10 @@ import org.glassfish.grizzly.http.util.Header;
  */
 public class JsonHttpHandler extends HttpHandler {
 
-    private final JsonFactory factory = new JsonFactory();
+    // Response message class.
+    public static class HelloMessage {
+      public final String message = "Hello, World!";
+    }
 
     @Override
     public void service(final Request request, final Response response)
@@ -22,22 +26,16 @@ public class JsonHttpHandler extends HttpHandler {
         response.setContentType("application/json");
         response.setHeader(Header.Server, Server.SERVER_VERSION);
 
-        JsonGenerator generator = null;
+        ObjectMapper MAPPER = new ObjectMapper();
 
-        try {
-            generator = factory.createGenerator(response.getOutputStream());
-            generator.writeStartObject();
-            generator.writeStringField("message", "Hello, world");
-            generator.writeEndObject();
-        } catch (IOException e) {
-            throw new IllegalStateException(e);
-        } finally {
-            if (generator != null) {
-                try {
-                    generator.close();
-                } catch (IOException e) {
-                }
-            }
+        // Write JSON encoded message to the response.
+        try
+        {
+          MAPPER.writeValue(response.getOutputStream(), new HelloMessage());
+        }
+        catch (IOException ioe) 
+        {
+          // do nothing
         }
     }
 

+ 1 - 1
grizzly-jersey/benchmark_config

@@ -20,7 +20,7 @@
       "database_os": "Linux",
       "display_name": "grizzly-jersey",
       "notes": "",
-      "versus": "servlet"
+      "versus": "grizzly"
     }
   }]
 }

+ 7 - 23
servicestack/setup_iis.ps1

@@ -1,23 +1,5 @@
 param($action)
 
-$ErrorActionPreference = 'Stop'
-
-# From http://zduck.com/2012/powershell-batch-files-exit-codes/
-function Exec
-{
-    [CmdletBinding()]
-    param (
-        [Parameter(Position=0, Mandatory=1)]
-        [scriptblock]$Command,
-        [Parameter(Position=1, Mandatory=0)]
-        [string]$ErrorMessage = "Execution of command failed.`n$Command"
-    )
-    & $Command
-    if ($LastExitCode -ne 0) {
-        throw "Exec: $ErrorMessage"
-    }
-}
-
 $wwwroot = "C:\FrameworkBenchmarks\servicestack\www"
 $source = "C:\FrameworkBenchmarks\servicestack\src"
 $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
@@ -25,15 +7,17 @@ $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
 
 # Stop
 if (Get-WebSite -Name Benchmarks) { Remove-WebSite -Name Benchmarks }
-Get-ChildItem -Path $wwwroot -Recurse -ErrorAction 'SilentlyContinue' | Remove-Item -Force -Recurse -ErrorAction 'SilentlyContinue'; 
-Remove-Item -Force -Recurse $wwwroot -ErrorAction 'SilentlyContinue'
+Get-ChildItem -Path $wwwroot -Recurse -ErrorAction 'SilentlyContinue' | Remove-Item -Force -Recurse -ErrorAction 'SilentlyContinue' | Out-Null
+Remove-Item -Force -Recurse $wwwroot -ErrorAction 'SilentlyContinue' | Out-Null
 
 if ($action -eq 'start') {
     # Create a website in IIS
-    New-Item -Path $wwwroot -Type directory | Out-Null
+    New-Item -Path $wwwroot -Type Directory -ErrorAction 'SilentlyContinue' | Out-Null
     New-WebSite -Name Benchmarks -Port 8080 -PhysicalPath $wwwroot
     
     # Build the project
-    Exec { & $msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /t:Clean }
-    Exec { & $msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /p:DeployOnBuild=true /p:PublishProfile=IIS }
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /t:RestorePackages
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /t:Clean
+    &$msbuild "$source\ServiceStackBenchmark.csproj" /p:Configuration=Release /p:Platform="x64" /p:DeployOnBuild=true /p:PublishProfile=IIS
 }
+

+ 11 - 1
servicestack/setup_nginx.py

@@ -16,6 +16,7 @@ def start(args):
     # build
     subprocess.check_call("rm -rf bin obj", shell=True, cwd=app)
     subprocess.check_call("xbuild /p:Configuration=Release", shell=True, cwd=app)
+    subprocess.check_call("sudo chown -R $USER:$USER /usr/local/etc/mono", shell=True)
     
     # nginx
     workers = 'worker_processes ' + str(args.max_threads) + ';'
@@ -35,5 +36,14 @@ def stop():
   
   subprocess.check_call("sudo /usr/local/nginx/sbin/nginx -c " + root + "/nginx.conf -s stop", shell=True)
   subprocess.check_call("rm -f " + root + "/nginx.upstream.conf", shell=True)
-  subprocess.check_call("pkill -9 mono", shell=True)
+  #
+  # stop mono
+  #
+  p = subprocess.Popen(['ps', 'aux'], stdout=subprocess.PIPE)
+  out, err = p.communicate()
+  for line in out.splitlines():
+    if 'mono-server' in line:
+      pid = int(line.split(None, 2)[1])
+      os.kill(pid, 9)
   return 0
+

+ 5 - 21
servicestack/setup_self.ps1

@@ -1,32 +1,16 @@
 param($action)
 
-$ErrorActionPreference = 'Stop'
-
-# From http://zduck.com/2012/powershell-batch-files-exit-codes/
-function Exec
-{
-    [CmdletBinding()]
-    param (
-        [Parameter(Position=0, Mandatory=1)]
-        [scriptblock]$Command,
-        [Parameter(Position=1, Mandatory=0)]
-        [string]$ErrorMessage = "Execution of command failed.`n$Command"
-    )
-    & $Command
-    if ($LastExitCode -ne 0) {
-        throw "Exec: $ErrorMessage"
-    }
-}
-
 $source = "C:\FrameworkBenchmarks\servicestack\src"
 $msbuild = "C:\Windows\Microsoft.NET\Framework64\v4.0.30319\MSBuild.exe"
 
 # Stop
-Get-Process | Where-Object { $_.Name -ieq "servicestack" } | Stop-Process
+Stop-Process -Name servicestack -ErrorAction 'SilentlyContinue' | Out-Null
 
 if ($action -eq 'start') {
     # Build the project
-    Exec { & $msbuild "$source\ServiceStackBenchmark.sln" /p:DownloadNuGetExe=true /p:RequireRestoreConsent=false /p:Configuration=Release /p:Platform="x64" /t:Rebuild }
-        
+    &$msbuild "$source\ServiceStackBenchmark.sln" /t:RestorePackages
+    &$msbuild "$source\ServiceStackBenchmark.sln" /p:DownloadNuGetExe=true /p:RequireRestoreConsent=false /p:Configuration=Release /p:Platform=x64 /t:Rebuild
+    
     Start-Process "$source\SelfHost\bin\Release\ServiceStackBenchmark.SelfHost.exe http://*:8080"
 }
+

+ 4 - 0
toolset/benchmark/benchmarker.py

@@ -110,6 +110,10 @@ class Benchmarker:
     self.__setup_database()
     self.__setup_client()
 
+    ## Check if wrk (and wrk-pipeline) is installed and executable, if not, raise an exception
+    #if not (os.access("/usr/local/bin/wrk", os.X_OK) and os.access("/usr/local/bin/wrk-pipeline", os.X_OK)):
+    #  raise Exception("wrk and/or wrk-pipeline are not properly installed. Not running tests.")
+
     ##########################
     # Run tests
     ##########################