forked from TechEmpower/FrameworkBenchmarks
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/TechEmpower/FrameworkBenc…
- Loading branch information
Showing
130 changed files
with
1,476 additions
and
1,056 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
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,9 @@ | ||
# From https://hub.docker.com/_/dart | ||
.dockerignore | ||
Dockerfile | ||
build/ | ||
.dart_tool/ | ||
.git/ | ||
.github/ | ||
.gitignore | ||
.packages |
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,5 @@ | ||
# https://dart.dev/guides/libraries/private-files | ||
# Created by `dart pub` | ||
.dart_tool/ | ||
*.lock | ||
!bin |
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,22 @@ | ||
# Dart 3 Benchmarking Test | ||
|
||
### Test Type Implementation Source Code | ||
|
||
- [JSON](server.dart) | ||
- [PLAINTEXT](server.dart) | ||
|
||
## Important Libraries | ||
|
||
The tests were run with: | ||
|
||
- [Dart v3.4.4](https://dart.dev/) | ||
|
||
## Test URLs | ||
|
||
### JSON | ||
|
||
http://localhost:8080/json | ||
|
||
### PLAINTEXT | ||
|
||
http://localhost:8080/plaintext |
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 @@ | ||
include: package:lints/recommended.yaml |
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,26 @@ | ||
{ | ||
"framework": "dart3", | ||
"tests": [ | ||
{ | ||
"default": { | ||
"json_url": "/json", | ||
"plaintext_url": "/plaintext", | ||
"port": 8080, | ||
"approach": "Stripped", | ||
"classification": "Platform", | ||
"database": "None", | ||
"framework": "None", | ||
"language": "Dart", | ||
"flavor": "None", | ||
"orm": "None", | ||
"platform": "None", | ||
"webserver": "None", | ||
"os": "Linux", | ||
"database_os": "Linux", | ||
"display_name": "dart3", | ||
"notes": "", | ||
"versus": "None" | ||
} | ||
} | ||
] | ||
} |
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,89 @@ | ||
import 'dart:convert'; | ||
import 'dart:io'; | ||
import 'dart:isolate'; | ||
|
||
final _encoder = JsonUtf8Encoder(); | ||
|
||
void main(List<String> _) async { | ||
/// Create an [Isolate] containinig an [HttpServer] | ||
/// for each processor after the first | ||
for (var i = 1; i < Platform.numberOfProcessors; i++) { | ||
await Isolate.spawn(_startServer, _); | ||
} | ||
|
||
/// Create a [HttpServer] for the first processor | ||
await _startServer(_); | ||
} | ||
|
||
/// Creates and setup a [HttpServer] | ||
Future<void> _startServer(List<String> _) async { | ||
/// Binds the [HttpServer] on `0.0.0.0:8080`. | ||
final server = await HttpServer.bind( | ||
InternetAddress('0.0.0.0', type: InternetAddressType.IPv4), | ||
8080, | ||
shared: true, | ||
); | ||
|
||
/// Sets [HttpServer]'s [serverHeader]. | ||
server | ||
..defaultResponseHeaders.clear() | ||
..serverHeader = 'dart'; | ||
|
||
/// Handles [HttpRequest]'s from [HttpServer]. | ||
await for (final request in server) { | ||
switch (request.uri.path) { | ||
case '/json': | ||
_jsonTest(request); | ||
break; | ||
case '/plaintext': | ||
_plaintextTest(request); | ||
break; | ||
default: | ||
_sendResponse(request, HttpStatus.notFound); | ||
} | ||
} | ||
} | ||
|
||
/// Completes the given [request] by writing the [bytes] with the given | ||
/// [statusCode] and [type]. | ||
void _sendResponse( | ||
HttpRequest request, | ||
int statusCode, { | ||
ContentType? type, | ||
List<int> bytes = const [], | ||
}) => | ||
request.response | ||
..statusCode = statusCode | ||
..headers.contentType = type | ||
..headers.date = DateTime.now() | ||
..contentLength = bytes.length | ||
..add(bytes) | ||
..close(); | ||
|
||
/// Completes the given [request] by writing the [response] as JSON. | ||
void _sendJson(HttpRequest request, Object response) => _sendResponse( | ||
request, | ||
HttpStatus.ok, | ||
type: ContentType.json, | ||
bytes: _encoder.convert(response), | ||
); | ||
|
||
/// Completes the given [request] by writing the [response] as plain text. | ||
void _sendText(HttpRequest request, String response) => _sendResponse( | ||
request, | ||
HttpStatus.ok, | ||
type: ContentType.text, | ||
bytes: utf8.encode(response), | ||
); | ||
|
||
/// Responds with the JSON test to the [request]. | ||
void _jsonTest(HttpRequest request) => _sendJson( | ||
request, | ||
const {'message': 'Hello, World!'}, | ||
); | ||
|
||
/// Responds with the plaintext test to the [request]. | ||
void _plaintextTest(HttpRequest request) => _sendText( | ||
request, | ||
'Hello, World!', | ||
); |
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,14 @@ | ||
|
||
FROM dart:3.5 AS builder | ||
|
||
COPY . /app | ||
WORKDIR /app | ||
RUN mkdir build | ||
RUN dart compile exe ./bin/server.dart -o build/server | ||
|
||
FROM scratch | ||
COPY --from=builder /runtime/ / | ||
COPY --from=builder /app/build /bin | ||
|
||
EXPOSE 8080 | ||
CMD ["server"] |
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,7 @@ | ||
name: dartbenchmark | ||
description: A benchmark of dart | ||
environment: | ||
sdk: '>=3.5.0 <4.0.0' | ||
|
||
dev_dependencies: | ||
lints: ^4.0.0 |
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 was deleted.
Oops, something went wrong.
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
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 was deleted.
Oops, something went wrong.
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,31 @@ | ||
defmodule Hello.WorldCache do | ||
use Nebulex.Cache, | ||
otp_app: :hello, | ||
adapter: Nebulex.Adapters.Local | ||
|
||
alias Hello.Models.World | ||
alias Hello.Repo | ||
|
||
def seed do | ||
if not __MODULE__.has_key?(:seeded) do | ||
World | ||
|> Repo.all() | ||
|> Enum.into([], &{&1.id, &1}) | ||
|> __MODULE__.put_all() | ||
|
||
__MODULE__.put(:seeded, true) | ||
end | ||
end | ||
|
||
def fetch(id) do | ||
case __MODULE__.get(id) do | ||
nil -> | ||
world = Repo.get(World, id) | ||
:ok = __MODULE__.put(id, world) | ||
world | ||
world -> | ||
world | ||
end | ||
end | ||
|
||
end |
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
Oops, something went wrong.