From 7ff905f5d39ac0d354c0c2969ef152252a4b9e0a Mon Sep 17 00:00:00 2001 From: cdeubler Date: Thu, 6 Sep 2012 00:27:53 +1000 Subject: [PATCH] Added Nancy Module and Tests --- .../AspNetFrameworksPerformance.csproj | 7 +++++ AspNetFrameworksPerformance/Global.asax.cs | 4 +++ AspNetFrameworksPerformance/Web.config | 24 ++++++++++++-- .../nancy/NancyPerformanceModule.cs | 31 +++++++++++++++++++ AspNetFrameworksPerformance/packages.config | 2 ++ LoadTests/ab_PerfTests.bat | 2 ++ 6 files changed, 68 insertions(+), 2 deletions(-) create mode 100644 AspNetFrameworksPerformance/nancy/NancyPerformanceModule.cs diff --git a/AspNetFrameworksPerformance/AspNetFrameworksPerformance.csproj b/AspNetFrameworksPerformance/AspNetFrameworksPerformance.csproj index 9ad35de..e2347e4 100644 --- a/AspNetFrameworksPerformance/AspNetFrameworksPerformance.csproj +++ b/AspNetFrameworksPerformance/AspNetFrameworksPerformance.csproj @@ -53,6 +53,12 @@ ..\packages\Microsoft.Web.Optimization.0.1\lib\net40\Microsoft.Web.Optimization.dll + + ..\packages\Nancy.0.12.0\lib\net40\Nancy.dll + + + ..\packages\Nancy.Hosting.Aspnet.0.12.0\lib\net40\Nancy.Hosting.Aspnet.dll + False ..\packages\Newtonsoft.Json.4.5.8\lib\net40\Newtonsoft.Json.dll @@ -121,6 +127,7 @@ + diff --git a/AspNetFrameworksPerformance/Global.asax.cs b/AspNetFrameworksPerformance/Global.asax.cs index 6be29bd..d42c451 100644 --- a/AspNetFrameworksPerformance/Global.asax.cs +++ b/AspNetFrameworksPerformance/Global.asax.cs @@ -21,6 +21,8 @@ protected void Application_Start() var formatters = GlobalConfiguration.Configuration.Formatters; formatters.Remove(formatters.XmlFormatter); + RouteTable.Routes.Ignore("nancy/{*pathInfo}"); + // API route - make sure this gets defined *BEFORE* MVC routes RouteTable.Routes.MapHttpRoute( name: "WebApiPerformanceAction", @@ -33,8 +35,10 @@ protected void Application_Start() } ); + FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); + //BundleConfig.RegisterBundles(BundleTable.Bundles); } diff --git a/AspNetFrameworksPerformance/Web.config b/AspNetFrameworksPerformance/Web.config index 52f297b..4db0114 100644 --- a/AspNetFrameworksPerformance/Web.config +++ b/AspNetFrameworksPerformance/Web.config @@ -19,7 +19,7 @@ - + @@ -28,7 +28,7 @@ - + @@ -41,12 +41,16 @@ + + + + @@ -87,4 +91,20 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/AspNetFrameworksPerformance/nancy/NancyPerformanceModule.cs b/AspNetFrameworksPerformance/nancy/NancyPerformanceModule.cs new file mode 100644 index 0000000..d2a31dd --- /dev/null +++ b/AspNetFrameworksPerformance/nancy/NancyPerformanceModule.cs @@ -0,0 +1,31 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Web; +using Nancy; + +namespace AspNetFrameworksPerformance.Controllers +{ + public class NancyPerformanceModule : NancyModule + { + public NancyPerformanceModule() + : base("/nancy") + { + Get["/"] = _ => + { + return "Hello Nancy"; + }; + + //Get["/NancyFx/HelloWorldCode"] = _ => + Get["/HelloWorldCode"] = _ => + { + return "Hello World. Time is: " + DateTime.Now.ToString(); + }; + + Get["/HelloWorldJson"] = _ => + { + return Response.AsJson(new Person()); + }; + } + } +} \ No newline at end of file diff --git a/AspNetFrameworksPerformance/packages.config b/AspNetFrameworksPerformance/packages.config index f8775c1..e893bc8 100644 --- a/AspNetFrameworksPerformance/packages.config +++ b/AspNetFrameworksPerformance/packages.config @@ -11,6 +11,8 @@ + + diff --git a/LoadTests/ab_PerfTests.bat b/LoadTests/ab_PerfTests.bat index dd52694..5cd2eb6 100644 --- a/LoadTests/ab_PerfTests.bat +++ b/LoadTests/ab_PerfTests.bat @@ -17,6 +17,7 @@ ab.exe -n100000 -c20 http://localhost/AspNetPerf/WcfService.svc/HelloWorld > Wcf ab.exe -n100000 -c20 http://localhost/aspnetperf/MvcPerformance/HelloWorldCode > Mvc.txt ab.exe -n100000 -c20 http://localhost/aspnetperf/api/HelloWorld > WebApi.txt ab.exe -n100000 -c20 http://localhost/AspNetPerf/WestWindCallbackHandler.ashx?Method=HelloWorld > WestWindCallback.txt +ab.exe -n100000 -c20 http://localhost/AspNetPerf/nancy/HelloWorldCode > NancyCode.txt REM JSON RESPONSES ab.exe -n100000 -c20 http://localhost/aspnetperf/Handler.ashx?action=json > HandlerJson.txt @@ -24,5 +25,6 @@ ab.exe -n100000 -c20 http://localhost/aspnetperf/MvcPerformance/HelloWorldJson > ab.exe -n100000 -c20 http://localhost/aspnetperf/api/HelloWorldJson > WebApiJson.txt ab.exe -n100000 -c20 http://localhost/AspNetPerf/WcfService.svc/HelloWorldJson > WcfJson.txt ab.exe -n100000 -c20 http://localhost/AspNetPerf/WestWindCallbackHandler.ashx?Method=HelloWorldJson > WestWindCallbackJson.txt +ab.exe -n100000 -c20 http://localhost/AspNetPerf/nancy/HelloWorldCode > NancyJson.txt pause \ No newline at end of file