Merge pull request #78 from dukefirehawk/feature/perf-1

Reduced debugging verbosity
This commit is contained in:
Thomas Hii 2022-08-31 21:35:11 +08:00 committed by GitHub
commit 272363052b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 31 additions and 30 deletions

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 7.0.1
* Reduced debugging verbosity
## 7.0.0 ## 7.0.0
* Require Dart >= 2.17 * Require Dart >= 2.17

View file

@ -45,9 +45,9 @@ class MariaDbExecutor extends QueryExecutor {
} }
} }
logger.warning('Query: $query'); //logger.warning('Query: $query');
logger.warning('Values: $params'); //logger.warning('Values: $params');
logger.warning('Returning Query: $returningQuery'); //logger.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) { if (returningQuery.isNotEmpty) {
// Handle insert, update and delete // Handle insert, update and delete
@ -77,17 +77,14 @@ class MariaDbExecutor extends QueryExecutor {
@override @override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async { Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
T? returnValue = await _connection.transaction((ctx) async { T? returnValue = await _connection.transaction((ctx) async {
// TODO: To be relooked at
try { try {
logger.fine('Entering transaction'); //logger.fine('Entering transaction');
//var tx = MariaDbExecutor(conn, logger: logger); //var tx = MariaDbExecutor(conn, logger: logger);
_transactionContext = ctx; _transactionContext = ctx;
return await f(this); return await f(this);
} catch (e) { } catch (e) {
logger.severe('Failed to run transaction', e); logger.severe('Failed to run transaction', e);
rethrow; rethrow;
} finally {
logger.fine('Exiting transaction');
} }
}); });

View file

@ -88,8 +88,8 @@ class MySqlExecutor extends QueryExecutor {
var value = substitutionValues[name]; var value = substitutionValues[name];
if (value is DateTime && value.isUtc) { if (value is DateTime && value.isUtc) {
var t = value.toLocal(); var t = value.toLocal();
logger.warning('Datetime deteted: $name'); //logger.warning('Datetime deteted: $name');
logger.warning('Datetime: UTC -> $value, Local -> $t'); //logger.warning('Datetime: UTC -> $value, Local -> $t');
substitutionValues[name] = t; substitutionValues[name] = t;
} }
@ -98,9 +98,9 @@ class MySqlExecutor extends QueryExecutor {
//var params = substitutionValues.values.toList(); //var params = substitutionValues.values.toList();
//var params = []; //var params = [];
logger.warning('Query: $query'); //logger.warning('Query: $query');
logger.warning('Values: $substitutionValues'); //logger.warning('Values: $substitutionValues');
//logger?.warning('Returning Query: $returningQuery'); //logger.warning('Returning Query: $returningQuery');
if (returningQuery.isNotEmpty) { if (returningQuery.isNotEmpty) {
// Handle insert, update and delete // Handle insert, update and delete
@ -108,10 +108,10 @@ class MySqlExecutor extends QueryExecutor {
if (query.startsWith("INSERT")) { if (query.startsWith("INSERT")) {
var result = await _connection.execute(query, substitutionValues); var result = await _connection.execute(query, substitutionValues);
logger.warning(result.lastInsertID); //logger.fine(result.lastInsertID);
query = returningQuery; query = returningQuery;
//logger?.warning('Result.insertId: ${result.insertId}'); //logger.fine('Result.insertId: ${result.insertId}');
// Has primary key // Has primary key
if (returningQuery.endsWith('.id=?')) { if (returningQuery.endsWith('.id=?')) {
query = query.replaceAll("?", ":id"); query = query.replaceAll("?", ":id");
@ -126,15 +126,15 @@ class MySqlExecutor extends QueryExecutor {
} }
} }
logger.warning('Query 2: $query'); //logger.warning('Query 2: $query');
logger.warning('Values 2: $substitutionValues'); //logger.warning('Values 2: $substitutionValues');
// Handle select // Handle select
return _connection.execute(query, substitutionValues).then((results) { return _connection.execute(query, substitutionValues).then((results) {
var tmpData = results.rows; // var tmpData = results.rows;
for (var element in tmpData) { //for (var element in tmpData) {
logger.warning("[Result] : ${element.assoc()}"); // logger.warning("[Result] : ${element.assoc()}");
} //}
return results.rows.map((r) => r.typedAssoc().values.toList()).toList(); return results.rows.map((r) => r.typedAssoc().values.toList()).toList();
}); });
@ -153,18 +153,16 @@ class MySqlExecutor extends QueryExecutor {
@override @override
Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async { Future<T> transaction<T>(FutureOr<T> Function(QueryExecutor) f) async {
logger.warning("Transaction"); //logger.warning("Transaction");
T? returnValue = await _connection.transactional((ctx) async { T? returnValue = await _connection.transactional((ctx) async {
try { try {
logger.fine('Entering transaction'); //logger.fine('Entering transaction');
var tx = MySqlExecutor(ctx, logger: logger); var tx = MySqlExecutor(ctx, logger: logger);
return await f(tx); return await f(tx);
} catch (e) { } catch (e) {
logger.severe('Failed to run transaction', e); logger.severe('Failed to run transaction', e);
rethrow; rethrow;
} finally {
logger.fine('Exiting transaction');
} }
}); });

View file

@ -1,5 +1,5 @@
name: angel3_orm_mysql name: angel3_orm_mysql
version: 7.0.0 version: 7.0.1
description: MySQL support for Angel3 ORM. Includes functionality for querying and transactions. description: MySQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_mysql

View file

@ -1,5 +1,9 @@
# Change Log # Change Log
## 7.0.1
* Reduced debugging verbosity
## 7.0.0 ## 7.0.0
* Require Dart >= 2.17 * Require Dart >= 2.17

View file

@ -107,7 +107,7 @@ class PostgreSqlExecutor extends QueryExecutor {
var txResult = await conn.transaction((ctx) async { var txResult = await conn.transaction((ctx) async {
try { try {
logger.fine('Entering transaction'); //logger.fine('Entering transaction');
var tx = PostgreSqlExecutor(ctx, logger: logger); var tx = PostgreSqlExecutor(ctx, logger: logger);
returnValue = await f(tx); returnValue = await f(tx);
@ -115,8 +115,6 @@ class PostgreSqlExecutor extends QueryExecutor {
} catch (e) { } catch (e) {
ctx.cancelTransaction(reason: e.toString()); ctx.cancelTransaction(reason: e.toString());
rethrow; rethrow;
} finally {
logger.fine('Exiting transaction');
} }
}); });
@ -176,7 +174,7 @@ class PostgreSqlExecutorPool extends QueryExecutor {
Future _open() async { Future _open() async {
if (_connections.isEmpty) { if (_connections.isEmpty) {
_connections.addAll(await Future.wait(List.generate(size, (_) async { _connections.addAll(await Future.wait(List.generate(size, (_) async {
logger.fine('Spawning connections...'); //logger.fine('Spawning connections...');
var conn = connectionFactory(); var conn = connectionFactory();
await conn.open(); await conn.open();
//return conn //return conn

View file

@ -1,5 +1,5 @@
name: angel3_orm_postgres name: angel3_orm_postgres
version: 7.0.0 version: 7.0.1
description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions. description: PostgreSQL support for Angel3 ORM. Includes functionality for querying and transactions.
homepage: https://angel3-framework.web.app/ homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_postgres repository: https://github.com/dukefirehawk/angel/tree/master/packages/orm/angel_orm_postgres