Browse Source

test for Dia (#6520)

Andrey Unger 4 years ago
parent
commit
a2b307bae3

+ 20 - 0
frameworks/Dart/dia/README.md

@@ -0,0 +1,20 @@
+# Dia Benchmarking Test
+
+### Test Type Implementation Source Code
+
+* [JSON](src/server.dart)
+* [PLAINTEXT](src/server.dart)
+
+## Important Libraries
+The tests were run with:
+* [Dart >=2.12.0 < 3.0.0](https://dart.dev)
+* [Dia ^0.0.7](https://pub.dev/packages/dia)
+
+## Test URLs
+### JSON
+
+http://localhost:8080/json
+
+### PLAINTEXT
+
+http://localhost:8080/plaintext

+ 26 - 0
frameworks/Dart/dia/benchmark_config.json

@@ -0,0 +1,26 @@
+{
+  "framework": "dia",
+  "tests": [
+    {
+      "default": {
+        "json_url": "/json",
+        "plaintext_url": "/plaintext",
+        "port": 8080,
+        "approach": "Realistic",
+        "classification": "Micro",
+        "database": "None",
+        "framework": "Dia",
+        "language": "Dart",
+        "flavor": "None",
+        "orm": "None",
+        "platform": "None",
+        "webserver": "None",
+        "os": "Linux",
+        "database_os": "Linux",
+        "display_name": "Dia",
+        "notes": "",
+        "versus": "None"
+      }
+    }
+  ]
+}

+ 13 - 0
frameworks/Dart/dia/dia.dockerfile

@@ -0,0 +1,13 @@
+FROM google/dart:2.12
+
+#ADD ./ /src
+WORKDIR /src
+
+COPY src/pubspec.yaml pubspec.yaml
+COPY src/server.dart server.dart
+
+RUN pub upgrade
+
+EXPOSE 8080
+
+CMD ["dart", "server.dart"]

+ 7 - 0
frameworks/Dart/dia/src/pubspec.yaml

@@ -0,0 +1,7 @@
+name: DiaBenchmark
+description: A benchmark of Dart Dia, a http simple framework
+environment:
+  sdk: ">=2.12.0 <3.0.0"
+dependencies:
+  dia: ^0.0.7
+  dia_router: ^0.0.5

+ 36 - 0
frameworks/Dart/dia/src/server.dart

@@ -0,0 +1,36 @@
+import 'dart:io';
+
+import 'package:dia/dia.dart';
+import 'package:dia_router/dia_router.dart';
+
+class CustomContext extends Context with Routing {
+  CustomContext(HttpRequest request) : super(request);
+}
+
+void main() {
+  final app = App<CustomContext>();
+
+  final router = Router<CustomContext>('/');
+
+  app.use((ctx, next) async {
+    ctx.set('Server', 'Dia');
+    ctx.set('Date', HttpDate.format(DateTime.now()).toString());
+    await next();
+  });
+
+  router.get('/plaintext', (ctx, next) async {
+    ctx.body = 'Hello, World!';
+  });
+
+  router.get('/json', (ctx, next) async {
+    ctx.contentType = ContentType.json;
+    ctx.body = '{"message":"Hello, World!"}';
+  });
+
+  app.use(router.middleware);
+
+  /// Start server listen on localhsot:8080
+  app
+      .listen('0.0.0.0', 8080)
+      .then((info) => print('Server started on http://0.0.0.0:8080'));
+}