Moved experiment to belatuk_rnd

This commit is contained in:
thomashii@dukefirehawk.com 2023-09-24 10:20:56 +08:00
parent 630c527381
commit c29c7b7049
33 changed files with 0 additions and 11492 deletions

View file

@ -1 +0,0 @@
include: package:lints/recommended.yaml

View file

@ -1,27 +0,0 @@
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'package:logging/logging.dart';
void main() async {
print("Starting up");
//Logger.root.onRecord.listen(print);
var app = Angel(logger: Logger('example'), reflector: MirrorsReflector());
var http = AngelHttp(app);
app.get("/", (req, res) => "Hello, world!");
// Simple fallback to throw a 404 on unknown paths.
/*
app.fallback((req, res) {
throw AngelHttpException.notFound(
message: 'Unknown path: "${req.uri?.path}"',
);
});
*/
await http.startServer('localhost', 3000);
print("End");
}

View file

@ -1,44 +0,0 @@
import 'dart:mirrors';
import 'package:example1/src/models.dart';
void main() {
final stopwatch = Stopwatch()..start();
var reflectedClass = reflect(Shape());
reflectedClass.invoke(#draw, []);
//reflectedClass.invoke(Symbol('draw'), []);
print('Reflection executed in ${stopwatch.elapsed.inMilliseconds} ms');
stopwatch.stop();
printAnnotationValue(String);
printAnnotationValue(Shape);
printAnnotationValue(Square);
}
class Shape {
void draw() => print("Draw Shape");
}
@Person('Will', 'Tom')
class Square {
void greetHii() {
print("Hii Welcome to flutter agency");
}
}
void printAnnotationValue(final Type clazz) {
final DeclarationMirror clazzDeclaration = reflectClass(clazz);
final ClassMirror someAnnotationMirror = reflectClass(Person);
final annotationInstsanceMirror =
clazzDeclaration.metadata.where((d) => d.type == someAnnotationMirror);
if (annotationInstsanceMirror.isEmpty) {
print('No annotated class found');
return;
}
final someAnnotationInstance =
(annotationInstsanceMirror.first.reflectee as Person);
print(someAnnotationInstance.firstName);
}

View file

@ -1,5 +0,0 @@
class Person {
final String firstName;
final String lastName;
const Person(this.firstName, this.lastName);
}

View file

@ -1,48 +0,0 @@
name: example1
version: 0.0.1
description: Example 1.
environment:
sdk: '>=2.18.0 <3.0.0'
dependencies:
angel3_container: ^7.0.0
angel3_http_exception: ^7.0.0
angel3_framework: ^7.0.0
angel3_model: ^7.0.0
angel3_route: ^7.0.0
angel3_mock_request: ^7.0.0
belatuk_merge_map: ^4.0.0
belatuk_combinator: ^4.0.0
belatuk_http_server: ^3.0.0
charcode: ^1.2.0
file: ^6.1.0
http_parser: ^4.0.0
http2: ^2.0.0
logging: ^1.0.0
matcher: ^0.12.10
meta: ^1.3.0
mime: ^1.0.0
path: ^1.8.0
quiver: ^3.0.1
recase: ^4.0.0
stack_trace: ^1.10.0
string_scanner: ^1.1.0
tuple: ^2.0.0
uuid: ^3.0.1
collection: ^1.15.0
dev_dependencies:
http: ^0.13.1
io: ^1.0.0
test: ^1.21.0
lints: ^2.0.0
# dependency_overrides:
# angel3_container:
# path: ../container/angel_container
# angel3_http_exception:
# path: ../http_exception
# angel3_model:
# path: ../model
# angel3_route:
# path: ../route
# angel3_mock_request:
# path: ../mock_request

View file

@ -1 +0,0 @@
include: package:lints/recommended.yaml

View file

@ -1,46 +0,0 @@
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
@Expose('/controller', method: 'GET')
class MyController extends Controller {
@Expose('/', method: 'GET')
Future<String> route1(RequestContext req, ResponseContext res) async {
return "My route";
}
}
@Expose('/sales', middleware: [process1])
class SalesController extends Controller {
@Expose('/', middleware: [process2])
Future<String> route1(RequestContext req, ResponseContext res) async {
return "Sales route";
}
}
bool process1(RequestContext req, ResponseContext res) {
res.write('Hello, ');
return true;
}
bool process2(RequestContext req, ResponseContext res) {
res.write('From Sales, ');
return true;
}
void main() async {
// Using Mirror Reflector
var app = Angel(reflector: MirrorsReflector());
// My Controller
app.container.registerSingleton<MyController>(MyController());
await app.mountController<MyController>();
// Sales Controller
app.container.registerSingleton<SalesController>(SalesController());
await app.mountController<SalesController>();
var http = AngelHttp(app);
var server = await http.startServer('localhost', 3000);
print("Angel server listening at ${http.uri}");
}

View file

@ -1,63 +0,0 @@
import 'package:angel3_container/mirrors.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
class Todo extends Model {
String? text;
String? over;
Todo({this.text, this.over});
Map<String, dynamic> toJson() {
return {
'text': text,
'over': over,
};
}
}
@Expose('/todo', method: 'GET')
class TodoController extends Controller {
@Expose('/')
Todo todo(Todo singleton) => singleton;
}
@Expose('/controller', method: 'GET')
class MyController extends Controller {
@Expose('/', method: 'GET')
Future<String> route1(RequestContext req, ResponseContext res) async {
return "My route";
}
//Todo todo(Todo singleton) => singleton;
}
@Expose('/sales', middleware: [process1])
class SalesController extends Controller {
@Expose('/', middleware: [process2])
Future<String> route1(RequestContext req, ResponseContext res) async {
return "Sales route";
}
}
bool process1(RequestContext req, ResponseContext res) {
res.write('Hello, ');
return true;
}
bool process2(RequestContext req, ResponseContext res) {
res.write('From Sales, ');
return true;
}
void main() async {
// Using Mirror Reflector
var app = Angel(reflector: MirrorsReflector());
await app.configure(MyController().configureServer);
await app.configure(SalesController().configureServer);
var http = AngelHttp(app);
var server = await http.startServer('localhost', 3000);
print("Angel server listening at ${http.uri}");
}

View file

@ -1,72 +0,0 @@
import 'package:angel3_container_generator/angel3_container_generator.dart';
import 'package:angel3_framework/angel3_framework.dart';
import 'package:angel3_framework/http.dart';
import 'example3_controller.reflectable.dart';
@contained
@Expose('/controller', method: 'GET')
class MyController extends Controller {
@Expose('/')
Order order(Order singleton) => singleton;
//Todo todo(Todo singleton) => singleton;
}
class Todo extends Model {
String? text;
String? over;
Todo({this.text, this.over});
Map<String, dynamic> toJson() {
return {
'text': text,
'over': over,
};
}
}
class FoodItem {
final String name;
final num price;
final num qty;
FoodItem(this.name, this.price, this.qty);
}
class Order {
FoodItem item;
String? get name => item.name;
Order(this.item);
}
void main() async {
//var reflector = const GeneratedReflector();
//Container container = Container(reflector);
//container.registerSingleton<SalesController>(SalesController());
// Using GeneratedReflector
initializeReflectable();
var app = Angel(reflector: GeneratedReflector());
// Using MirrorReflector
//var app = Angel(reflector: MirrorsReflector());
//await app.configure(MyController().configureServer);
// My Controller
//app.container.registerSingleton<MyController>(MyController());
//await app.mountController<MyController>();
await app.configure(MyController().configureServer);
// Sales Controller
//app.container.registerSingleton<SalesController>(SalesController());
//await app.mountController<SalesController>();
var http = AngelHttp(app);
var server = await http.startServer('localhost', 3000);
print("Angel server listening at ${http.uri}");
}

View file

@ -1,44 +0,0 @@
import 'package:example2/src/models.dart';
void main() {
final stopwatch = Stopwatch()..start();
//var reflectedClass = reflect(Shape());
//reflectedClass.invoke(#draw, []);
//reflectedClass.invoke(Symbol('draw'), []);
print('Reflection executed in ${stopwatch.elapsed.inMilliseconds} ms');
stopwatch.stop();
//printAnnotationValue(String);
//printAnnotationValue(Shape);
//printAnnotationValue(Square);
}
class Shape {
void draw() => print("Draw Shape");
}
@Person('Will', 'Tom')
class Square {
void greetHii() {
print("Hii Welcome to flutter agency");
}
}
/*
void printAnnotationValue(final Type clazz) {
final DeclarationMirror clazzDeclaration = reflectClass(clazz);
final ClassMirror someAnnotationMirror = reflectClass(Person);
final annotationInstsanceMirror =
clazzDeclaration.metadata.where((d) => d.type == someAnnotationMirror);
if (annotationInstsanceMirror.isEmpty) {
print('No annotated class found');
return;
}
final someAnnotationInstance =
(annotationInstsanceMirror.first.reflectee as Person);
print(someAnnotationInstance.firstName);
}
*/

View file

@ -1,9 +0,0 @@
targets:
$default:
builders:
reflectable:
generate_for:
#- lib/**_controller.dart
- bin/**_controller.dart
options:
formatted: true

View file

@ -1,15 +0,0 @@
import 'package:angel3_container_generator/angel3_container_generator.dart';
import 'package:angel3_framework/angel3_framework.dart';
@Expose('/hr')
class HrController extends Controller {
@Expose('/')
landingPage() => "Hello, world!";
}
@contained
class SalesController extends Controller {
landingPage() => "Hello, world!";
}
void main() {}

View file

@ -1,5 +0,0 @@
class Person {
final String firstName;
final String lastName;
const Person(this.firstName, this.lastName);
}

View file

@ -1,53 +0,0 @@
name: example2
version: 0.0.1
description: Example 2.
environment:
sdk: '>=3.0.0 <4.0.0'
dependencies:
angel3_container: ^7.1.0-beta.1
angel3_container_generator: ^7.1.0-beta.1
angel3_http_exception: ^7.0.0
angel3_framework: ^7.0.0
angel3_model: ^7.0.0
angel3_route: ^7.0.0
angel3_mock_request: ^7.0.0
belatuk_merge_map: ^4.0.0
belatuk_combinator: ^4.0.0
belatuk_http_server: ^3.0.0
charcode: ^1.2.0
file: ^6.1.0
http_parser: ^4.0.0
http2: ^2.0.0
logging: ^1.0.0
matcher: ^0.12.10
meta: ^1.3.0
mime: ^1.0.0
path: ^1.8.0
quiver: ^3.0.1
recase: ^4.0.0
stack_trace: ^1.10.0
string_scanner: ^1.1.0
tuple: ^2.0.0
uuid: ^3.0.1
collection: ^1.15.0
reflectable: ^4.0.2
dev_dependencies:
build_runner: ^2.1.2
http: ^0.13.1
io: ^1.0.0
test: ^1.21.0
lints: ^2.0.0
# dependency_overrides:
# angel3_container:
# path: ../../../packages/container/angel_container
# angel3_container_generator:
# path: ../../../packages/container/angel_container_generator
# angel3_framework:
# path: ../../../packages/framework
# angel3_model:
# path: ../model
# angel3_route:
# path: ../route
# angel3_mock_request:
# path: ../mock_request

View file

@ -1,14 +0,0 @@
import 'package:angel3_container_generator/angel3_container_generator.dart';
import 'package:angel3_framework/angel3_framework.dart';
@Expose('/hr')
class HrController extends Controller {
@Expose('/')
landingPage() => "Hello, world!";
}
@contained
class SalesController extends Controller {
landingPage() => "Hello, world!";
}

View file

@ -1,6 +0,0 @@
Primary Authors
===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
The current main maintainer of the code base.

View file

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2021, dukefirehawk.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1 +0,0 @@
include: package:lints/recommended.yaml

View file

@ -1,93 +0,0 @@
import 'dart:io';
import 'package:mysql_client/mysql_client.dart';
import 'package:mysql1/mysql1.dart';
void main() async {
print("=== Start 'mysql1' driver test");
await testMySQL1Driver().catchError((error, stackTrace) {
print(error);
});
print("=== End test");
print(" ");
print("=== Start 'mysql_client' driver test");
await testMySQLClientDriver().catchError((error, stackTrace) {
print(error);
});
print("=== End test");
print(" ");
//sleep(Duration(seconds: 5));
exit(0);
}
Future<void> testMySQLClientDriver() async {
var connection = await MySQLConnection.createConnection(
host: "localhost",
port: 3306,
databaseName: "orm_test",
userName: "test",
password: "test123",
secure: false);
await connection.connect(timeoutMs: 30000);
print(">Test Select All");
var result = await connection.execute("SELECT * from users");
print("Total records: ${result.rows.length}");
print(">Test Insert");
var params = {
"username": "test",
"password": "test123",
"email": "test@demo.com",
"updatedAt": DateTime.parse("1970-01-01 00:00:00")
};
result = await connection.execute(
"INSERT INTO users (username, password, email, updated_at) VALUES (:username, :password, :email, :updatedAt)",
params);
print("Last inserted ID: ${result.lastInsertID}");
print(">Test Select By ID");
result = await connection.execute(
"SELECT * from users where id=:id", {"id": result.lastInsertID.toInt()});
print("Read record: ${result.rows.first.assoc()}");
}
Future<void> testMySQL1Driver() async {
var settings = ConnectionSettings(
host: 'localhost',
port: 3306,
db: 'orm_test',
user: 'test',
password: 'test123',
timeout: Duration(seconds: 60));
var connection = await MySqlConnection.connect(settings);
print(">Test Select All");
var result = await connection.query("SELECT * from users");
print("Total records: ${result.length}");
print(">Test Insert");
var params = [
"test",
"test123",
"test@demo.com",
DateTime.parse("1970-01-01 00:00:00").toUtc()
];
// DateTime.parse("1970-01-01 00:00:01").toUtc()
result = await connection.query(
"INSERT INTO users (username, password, email, updated_at) VALUES (?, ?, ?, ?)",
params);
print("Last inserted ID: ${result.insertId}");
print(">Test Select By ID");
result = await connection
.query("SELECT * from users where id=?", [result.insertId]);
print("Read record: ${result.first.values}");
var d = DateTime.parse("1970-01-01 00:00:00").toUtc();
print("Local time: ${d.toLocal()}");
}

View file

@ -1,53 +0,0 @@
import 'dart:io';
import 'package:postgres/postgres.dart';
void main() async {
/*
* Granting permission in postgres
* grant all privileges on database orm_test to test;
* grant all privileges on sequence users_id_seq to test;
*/
print("=== Start 'postgres' driver test");
await testPgDriver().catchError((error, stackTrace) {
print(error);
});
print("=== End test");
print(" ");
exit(0);
}
Future<void> testPgDriver() async {
var conn = PostgreSQLConnection('localhost', 5432, 'orm_test',
username: 'test', password: 'test123');
await conn.open();
print(">Test Select All");
var result = await conn.query("SELECT * from users");
print("Total records: ${result.length}");
for (var row in result) {
print(row[0]);
for (var element in row) {
print(element);
}
}
print(">Test Insert");
var params = {
"username": "test",
"password": "test123",
"email": "test@demo.com",
"updatedAt": DateTime.parse("1970-01-01 00:00:00")
};
result = await conn.query(
"INSERT INTO users (username, password, email, updated_at) VALUES (@username, @password, @email, @updatedAt)",
substitutionValues: params);
//print("Last inserted ID: ${result.}");
//print(">Test Select By ID");
//result = await conn.query("SELECT * from users where id=@id",
// substitutionValues: {"id": result});
//print("Read record: ${result.length}");
}

View file

@ -1,14 +0,0 @@
name: performance_tool
version: 1.0.0
description: Angel3 performance testing tool
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
published_to: none
dependencies:
mysql1: ^0.20.0
mysql_client: ^0.0.24
postgres: ^2.4.1
postgres_pool: ^2.1.3
dev_dependencies:
lints: ^2.0.0

View file

@ -1,6 +0,0 @@
Primary Authors
===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
The current main maintainer of the code base.

View file

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2021, dukefirehawk.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1 +0,0 @@
include: package:lints/recommended.yaml

View file

@ -1,22 +0,0 @@
import 'dart:isolate';
Future<void> runApp(var message) async {
var stopwatch = Stopwatch()..start();
// Do something
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
}
void main() async {
var concurrency = 6000;
for (var i = 0; i < concurrency; i++) {
Isolate.spawn(runApp, 'Instance_$i');
}
await Future.delayed(const Duration(seconds: 10));
//print("Exit");
}

View file

@ -1,11 +0,0 @@
name: performance_tool
version: 1.0.0
description: Angel3 performance testing tool
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
published_to: none
dependencies:
http: ^0.13.4
dev_dependencies:
lints: ^2.0.0

View file

@ -1,6 +0,0 @@
Primary Authors
===============
* __[Thomas Hii](dukefirehawk.apps@gmail.com)__
The current main maintainer of the code base.

View file

@ -1,29 +0,0 @@
BSD 3-Clause License
Copyright (c) 2021, dukefirehawk.com
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View file

@ -1 +0,0 @@
include: package:lints/recommended.yaml

View file

@ -1,104 +0,0 @@
import 'dart:isolate';
import 'package:http/http.dart' as http;
Future<void> fortunes(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/fortunes');
var response = await http.get(url);
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
if (response.statusCode == 200) {
print('Execution($message): success');
} else {
print('Execution($message): error');
}
}
Future<void> plaintext(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/plaintext');
var response = await http.get(url);
if (response.statusCode == 200) {
print('Execution($message): ${response.body}.');
} else {
print('Execution($message): error');
}
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
}
Future<void> json(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/json');
var response = await http.get(url);
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
if (response.statusCode == 200) {
print('Execution($message): success');
} else {
print('Execution($message): error');
}
}
Future<void> dbUpdate(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/updates', {'queries': "5"});
var response = await http.get(url);
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
if (response.statusCode == 200) {
print('Execution($message): success');
} else {
print('Execution($message): error');
}
}
Future<void> dbSingleQuery(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/db');
var response = await http.get(url);
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
if (response.statusCode == 200) {
print('Execution($message): success');
} else {
print('Execution($message): error');
}
}
Future<void> dbMultipleQuery(var message) async {
var stopwatch = Stopwatch()..start();
var url = Uri.http('localhost:8080', '/query', {'queries': "5"});
var response = await http.get(url);
print('Execution($message) Time: ${stopwatch.elapsed.inMilliseconds}ms');
stopwatch.stop();
if (response.statusCode == 200) {
print('Execution($message): success');
} else {
print('Execution($message): error');
}
}
void main() async {
var concurrency = 2000;
for (var i = 0; i < concurrency; i++) {
Isolate.spawn(dbSingleQuery, 'Instance_$i');
}
await Future.delayed(const Duration(seconds: 10));
//print("Exit");
}

View file

@ -1,11 +0,0 @@
name: performance_tool
version: 1.0.0
description: Angel3 performance testing tool
publish_to: none
environment:
sdk: '>=3.0.0 <4.0.0'
published_to: none
dependencies:
http: ^0.13.4
dev_dependencies:
lints: ^2.0.0

View file

@ -1,19 +0,0 @@
### JSON Test
GET http://localhost:8080/json HTTP/1.1
### Plaintext Test
GET http://localhost:8080/plaintext HTTP/1.1
### Fortunes Test
GET http://localhost:8080/fortunes HTTP/1.1
### Db Test
GET http://localhost:8080/db HTTP/1.1
### Query test
GET http://localhost:8080/query?queries=20 HTTP/1.1
### Update Test
GET http://localhost:8080/updates?queries=20 HTTP/1.1