forked from bgrainger/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51b57df
commit 32f2424
Showing
9 changed files
with
257 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
[Oo]bj/ | ||
[Bb]in/ | ||
TestResults/ | ||
.nuget/ | ||
*.sln.ide/ | ||
_ReSharper.*/ | ||
.idea/ | ||
packages/ | ||
artifacts/ | ||
PublishProfiles/ | ||
.vs/ | ||
*.user | ||
*.suo | ||
*.cache | ||
*.docstates | ||
_ReSharper.* | ||
nuget.exe | ||
*net45.csproj | ||
*net451.csproj | ||
*k10.csproj | ||
*.psess | ||
*.vsp | ||
*.pidb | ||
*.userprefs | ||
*DS_Store | ||
*.ncrunchsolution | ||
*.*sdf | ||
*.ipch | ||
*.swp | ||
*~ | ||
.build/ | ||
.testPublish/ | ||
launchSettings.json | ||
BenchmarkDotNet.Artifacts/ | ||
BDN.Generated/ | ||
binaries/ | ||
global.json | ||
*.sln |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# girrafe Tests on Linux | ||
This includes tests for plaintext and json serialization. | ||
|
||
## Infrastructure Software Versions | ||
|
||
**Language** | ||
|
||
* F# 4.1 | ||
|
||
**Platforms** | ||
|
||
* .NET Core (Windows and Linux) | ||
|
||
**Web Servers** | ||
|
||
* [Kestrel](https://github.com/aspnet/KestrelHttpServer) | ||
|
||
**Web Stack** | ||
|
||
* [giraffe](https://github.com/giraffe-fsharp/Giraffe) | ||
* ASP.NET Core | ||
|
||
## Paths & Source for Tests | ||
|
||
* [Plaintext](src/App/Programs.fs): "/plaintext" | ||
* [JSON serialization](src/App/Programs.fs): "/json" | ||
* [JSON serialization via utf8json lib](src/App/Programs.fs): "/jsonutf8" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
{ | ||
"framework": "giraffe", | ||
"tests": [ | ||
{ | ||
"default": { | ||
"plaintext_url": "/plaintext", | ||
"json_url": "/json", | ||
"port": 8080, | ||
"approach": "Realistic", | ||
"classification": "fullstack", | ||
"database": "None", | ||
"framework": "giraffe", | ||
"language": "F#", | ||
"orm": "Raw", | ||
"platform": ".NET", | ||
"flavor": "CoreCLR", | ||
"webserver": "Kestrel", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "Giraffe", | ||
"notes": "", | ||
"versus": "aspcore" | ||
} | ||
}, | ||
{ | ||
"utf8json": { | ||
"json_url": "/json", | ||
"port": 8080, | ||
"approach": "Realistic", | ||
"classification": "fullstack", | ||
"database": "None", | ||
"framework": "giraffe", | ||
"language": "F#", | ||
"orm": "Raw", | ||
"platform": ".NET", | ||
"flavor": "CoreCLR", | ||
"webserver": "Kestrel", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "Giraffe", | ||
"notes": "", | ||
"versus": "aspcore" | ||
} | ||
}, | ||
{ | ||
"utf8plaintext": { | ||
"plaintext_url": "/plaintext", | ||
"port": 8080, | ||
"approach": "Realistic", | ||
"classification": "fullstack", | ||
"database": "None", | ||
"framework": "giraffe", | ||
"language": "F#", | ||
"orm": "Raw", | ||
"platform": ".NET", | ||
"flavor": "CoreCLR", | ||
"webserver": "Kestrel", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "Giraffe", | ||
"notes": "", | ||
"versus": "aspcore" | ||
} | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM microsoft/dotnet:2.1-sdk-stretch AS build | ||
WORKDIR /app | ||
COPY src/App . | ||
RUN dotnet publish -c Release -o out | ||
|
||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime | ||
ENV ASPNETCORE_URLS http://+:8080 | ||
ENV COMPlus_ReadyToRun 0 | ||
WORKDIR /app | ||
COPY --from=build /app/out ./ | ||
|
||
ENTRYPOINT ["dotnet", "App.dll"] |
12 changes: 12 additions & 0 deletions
12
frameworks/FSharp/giraffe/giraffe-utf8plaintext.dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM microsoft/dotnet:2.1-sdk-stretch AS build | ||
WORKDIR /app | ||
COPY src/App . | ||
RUN dotnet publish -c Release -o out | ||
|
||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime | ||
ENV ASPNETCORE_URLS http://+:8080 | ||
ENV COMPlus_ReadyToRun 0 | ||
WORKDIR /app | ||
COPY --from=build /app/out ./ | ||
|
||
ENTRYPOINT ["dotnet", "App.dll"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
FROM microsoft/dotnet:2.1-sdk-stretch AS build | ||
WORKDIR /app | ||
COPY src/App . | ||
RUN dotnet publish -c Release -o out | ||
|
||
FROM microsoft/dotnet:2.1-aspnetcore-runtime AS runtime | ||
ENV ASPNETCORE_URLS http://+:8080 | ||
ENV COMPlus_ReadyToRun 0 | ||
WORKDIR /app | ||
COPY --from=build /app/out ./ | ||
|
||
ENTRYPOINT ["dotnet", "App.dll", "stock"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>netcoreapp2.1</TargetFramework> | ||
<DebugType>portable</DebugType> | ||
<AssemblyName>App</AssemblyName> | ||
<OutputType>Exe</OutputType> | ||
<EnableDefaultContentItems>false</EnableDefaultContentItems> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.AspNetCore.Hosting" Version="2.1.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Server.Kestrel" Version="2.1.0" /> | ||
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="2.1.0" /> | ||
<PackageReference Include="Giraffe" Version="1.1.0" /> | ||
<PackageReference Include="Utf8Json" Version="1.3.7" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Compile Include="Program.fs" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Update="FSharp.Core" Version="4.5.0" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
module App.App | ||
|
||
open Microsoft.AspNetCore.Hosting | ||
open Giraffe | ||
|
||
[<CLIMutable>] | ||
type JsonMessage = { message : string } | ||
|
||
[<CLIMutable>][<Struct>] | ||
type JsonStructMessage = { message : string } | ||
|
||
type Implementation = Stock | Custom | ||
|
||
module Routes = | ||
|
||
let stock : HttpHandler list = | ||
[ route "/plaintext" >=> text "Hello, World!" | ||
route "/json" >=> json { JsonMessage.message = "Hello, World!" } ] | ||
|
||
let custom : HttpHandler list = | ||
let inline contentLength (x:int32) = new System.Nullable<int64>( int64 x ) | ||
|
||
let json data : HttpHandler = | ||
let bytes = Utf8Json.JsonSerializer.Serialize(data) | ||
fun _ ctx -> | ||
ctx.Response.ContentLength <- contentLength ( bytes.Length ) | ||
ctx.Response.ContentType <- "application/json" | ||
ctx.Response.StatusCode <- 200 | ||
ctx.WriteBytesAsync bytes | ||
|
||
let bytes = System.Text.Encoding.UTF8.GetBytes "Hello, World!" | ||
let text : HttpHandler = | ||
fun _ ctx -> | ||
ctx.Response.ContentLength <- contentLength ( bytes.Length ) | ||
ctx.Response.ContentType <- "text/plain" | ||
ctx.Response.StatusCode <- 200 | ||
ctx.WriteBytesAsync bytes | ||
|
||
[ route "/plaintext" >=> text | ||
route "/json" >=> json { JsonStructMessage.message = "Hello, World!" } ] | ||
|
||
let webApp implementation = | ||
match implementation with | ||
| Stock -> GET >=> choose Routes.stock | ||
| Custom -> GET >=> choose Routes.custom | ||
|
||
[<EntryPoint>] | ||
let main args = | ||
let implementation = | ||
match args with | ||
| [| "stock" |] -> Stock | ||
| _ -> Custom | ||
|
||
printfn "Running with %A implementation" implementation | ||
|
||
WebHostBuilder() | ||
.UseKestrel() | ||
.Configure(fun app -> app.UseGiraffe (webApp implementation)) | ||
.ConfigureServices(fun services -> services.AddGiraffe() |> ignore) | ||
.Build() | ||
.Run() | ||
0 |