use less memory for debugCallLength Map (#48)
* use less memory for debugCallLength Map * ignore errors in default debug functions
This commit is contained in:
@@ -101,14 +101,36 @@ final Stopwatch sw = Stopwatch()..start();
|
||||
bool printStarts = false;
|
||||
|
||||
void Function(String call)? debugStart = (call) {
|
||||
if (printStarts) print("MONERO: $call");
|
||||
debugCallLength[call] ??= <int>[];
|
||||
debugCallLength[call]!.add(sw.elapsedMicroseconds);
|
||||
try {
|
||||
if (printStarts) print("MONERO: $call");
|
||||
debugCallLength[call] ??= <int>[];
|
||||
debugCallLength[call]!.add(sw.elapsedMicroseconds);
|
||||
} catch (e) {}
|
||||
};
|
||||
void debugChores() {
|
||||
for (var key in debugCallLength.keys) {
|
||||
if (debugCallLength[key]!.length > 1000000) {
|
||||
final elm =
|
||||
debugCallLength[key]!.reduce((value, element) => value + element);
|
||||
debugCallLength[key]!.clear();
|
||||
debugCallLength["${key}_1M"] ??= <int>[];
|
||||
debugCallLength["${key}_1M"]!.add(elm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int debugCount = 0;
|
||||
|
||||
void Function(String call)? debugEnd = (call) {
|
||||
final id = debugCallLength[call]!.length - 1;
|
||||
debugCallLength[call]![id] =
|
||||
sw.elapsedMicroseconds - debugCallLength[call]![id];
|
||||
try {
|
||||
final id = debugCallLength[call]!.length - 1;
|
||||
if (++debugCount > 1000000) {
|
||||
debugCount = 0;
|
||||
debugChores();
|
||||
}
|
||||
debugCallLength[call]![id] =
|
||||
sw.elapsedMicroseconds - debugCallLength[call]![id];
|
||||
} catch (e) {}
|
||||
};
|
||||
void Function(String call, dynamic error)? errorHandler = (call, error) {
|
||||
print("$call: $error");
|
||||
|
||||
@@ -101,14 +101,36 @@ final Stopwatch sw = Stopwatch()..start();
|
||||
bool printStarts = false;
|
||||
|
||||
void Function(String call)? debugStart = (call) {
|
||||
if (printStarts) print("MONERO: $call");
|
||||
debugCallLength[call] ??= <int>[];
|
||||
debugCallLength[call]!.add(sw.elapsedMicroseconds);
|
||||
try {
|
||||
if (printStarts) print("MONERO: $call");
|
||||
debugCallLength[call] ??= <int>[];
|
||||
debugCallLength[call]!.add(sw.elapsedMicroseconds);
|
||||
} catch (e) {}
|
||||
};
|
||||
void debugChores() {
|
||||
for (var key in debugCallLength.keys) {
|
||||
if (debugCallLength[key]!.length > 1000000) {
|
||||
final elm =
|
||||
debugCallLength[key]!.reduce((value, element) => value + element);
|
||||
debugCallLength[key]!.clear();
|
||||
debugCallLength["${key}_1M"] ??= <int>[];
|
||||
debugCallLength["${key}_1M"]!.add(elm);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int debugCount = 0;
|
||||
|
||||
void Function(String call)? debugEnd = (call) {
|
||||
final id = debugCallLength[call]!.length - 1;
|
||||
debugCallLength[call]![id] =
|
||||
sw.elapsedMicroseconds - debugCallLength[call]![id];
|
||||
try {
|
||||
final id = debugCallLength[call]!.length - 1;
|
||||
if (++debugCount > 1000000) {
|
||||
debugCount = 0;
|
||||
debugChores();
|
||||
}
|
||||
debugCallLength[call]![id] =
|
||||
sw.elapsedMicroseconds - debugCallLength[call]![id];
|
||||
} catch (e) {}
|
||||
};
|
||||
void Function(String call, dynamic error)? errorHandler = (call, error) {
|
||||
print("$call: $error");
|
||||
|
||||
Reference in New Issue
Block a user