Skip to content

Unneded string interpolation of characteristics is very resource hungryΒ #708

@bobatsar

Description

@bobatsar

The logger output in reactive_ble_mobile_platform.dart, is evaluated for each received message. Especially the interpolation of the characteristic is quite resource hungry. We are receiving a lot of characteristics data and this string interpolation takes up about 10-15% of CPU usage for our data handling.

_logger?.log(
'Received $CharacteristicValue(characteristic: ${update.characteristic}, result: ${update.runtimeType})',
);

Unfortunately the logger is always initialized via the following code and I don't see any way to disable it.

Future<void> initialize() async {
if (_initialization == null) {
_debugLogger = DebugLogger(
'REACTIVE_BLE',
print,
);

Can this be refactored, that the logger does not have to be initialized and can be set to null if not used? AFAIK then the interpolation would not be executed, resulting in less CPU usage.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions