-
-
Save alexeychirkov/1deba9bbfa899538761bd04e7a1dbaa0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Array "mo:base/Array"; | |
import Iter "mo:base/Iter"; | |
import Prim "mo:prim"; | |
actor { | |
type CanisterMemoryInfo = { | |
rts_version : Text; | |
rts_memory_size: Nat; | |
rts_heap_size: Nat; | |
rts_total_allocation: Nat; | |
rts_reclaimed : Nat; | |
rts_max_live_size : Nat; | |
}; | |
var store: [Nat] = []; | |
public query func getSize() : async Nat { | |
store.size() | |
}; | |
public func appendData(count: Nat) : async (Nat, CanisterMemoryInfo) { | |
Iter.iterate<Nat>(Iter.range(1, count), func(x, _index) { | |
store := Array.append<Nat>(store, Array.make(x)); | |
}); | |
(store.size(), await getCanisterMemoryInfo()) | |
}; | |
public query func getCanisterMemoryInfo() : async CanisterMemoryInfo { | |
return { | |
rts_version = Prim.rts_version(); | |
rts_memory_size = Prim.rts_memory_size(); | |
rts_heap_size = Prim.rts_heap_size(); | |
rts_total_allocation = Prim.rts_total_allocation(); | |
rts_reclaimed = Prim.rts_reclaimed(); | |
rts_max_live_size = Prim.rts_max_live_size(); | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment