diff options
| author | cyan <cyjan@mrcyjanek.net> | 2024-09-05 09:50:47 +0000 |
|---|---|---|
| committer | cyan <cyjan@mrcyjanek.net> | 2024-09-05 09:50:47 +0000 |
| commit | fca0c1ec5cc735b550fb55c44040b08e084b566a (patch) | |
| tree | 801a558234567e39ebefaa2f0e0e5fa38240916c /impls/monero.dart/lib | |
| parent | 1e22390f512f97c89b6b4c75da4958c16316da22 (diff) | |
use less memory for debugCallLength Map
Diffstat (limited to 'impls/monero.dart/lib')
| -rw-r--r-- | impls/monero.dart/lib/monero.dart | 18 | ||||
| -rw-r--r-- | impls/monero.dart/lib/wownero.dart | 18 |
2 files changed, 36 insertions, 0 deletions
diff --git a/impls/monero.dart/lib/monero.dart b/impls/monero.dart/lib/monero.dart index 997f1b6..ab4210e 100644 --- a/impls/monero.dart/lib/monero.dart +++ b/impls/monero.dart/lib/monero.dart @@ -105,8 +105,26 @@ void Function(String call)? debugStart = (call) { debugCallLength[call] ??= <int>[]; debugCallLength[call]!.add(sw.elapsedMicroseconds); }; +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; + if (++debugCount > 1000000) { + debugCount = 0; + debugChores(); + } debugCallLength[call]![id] = sw.elapsedMicroseconds - debugCallLength[call]![id]; }; diff --git a/impls/monero.dart/lib/wownero.dart b/impls/monero.dart/lib/wownero.dart index e87488c..9e2cb3b 100644 --- a/impls/monero.dart/lib/wownero.dart +++ b/impls/monero.dart/lib/wownero.dart @@ -105,8 +105,26 @@ void Function(String call)? debugStart = (call) { debugCallLength[call] ??= <int>[]; debugCallLength[call]!.add(sw.elapsedMicroseconds); }; +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; + if (++debugCount > 1000000) { + debugCount = 0; + debugChores(); + } debugCallLength[call]![id] = sw.elapsedMicroseconds - debugCallLength[call]![id]; }; |
