diff --git a/nostrdb/NdbNote.swift b/nostrdb/NdbNote.swift index 081cccd1..4b54253c 100644 --- a/nostrdb/NdbNote.swift +++ b/nostrdb/NdbNote.swift @@ -53,12 +53,14 @@ class NdbNote: Encodable, Equatable, Hashable { self.owned = owned_size != nil self.count = owned_size ?? 0 + #if DEBUG_NOTE_SIZE if let owned_size { NdbNote.total_ndb_size += Int(owned_size) NdbNote.notes_created += 1 print("\(NdbNote.notes_created) ndb_notes, \(NdbNote.total_ndb_size) bytes") } + #endif } @@ -102,10 +104,12 @@ class NdbNote: Encodable, Equatable, Hashable { deinit { if self.owned { + #if DEBUG_NOTE_SIZE NdbNote.total_ndb_size -= Int(count) NdbNote.notes_created -= 1 print("\(NdbNote.notes_created) ndb_notes, \(NdbNote.total_ndb_size) bytes") + #endif free(note) } } @@ -135,8 +139,10 @@ class NdbNote: Encodable, Equatable, Hashable { try container.encode(tags, forKey: .tags) } + #if DEBUG_NOTE_SIZE static var total_ndb_size: Int = 0 static var notes_created: Int = 0 + #endif init?(content: String, keypair: Keypair, kind: UInt32 = 1, tags: [[String]] = [], createdAt: UInt32 = UInt32(Date().timeIntervalSince1970)) {