簡體   English   中英

如何在 Clojure 中使用.getObjectSize?

[英]How to use .getObjectSize in Clojure?

在 Clojure 中,確定 map 大小的最佳方法是什么? 導入java庫“java.lang.instrument.Instrumentation”並使用.getObjectSize。 但是,無法導入該庫。 請評論如何正確導入庫。

; Load the instrumentation namespace to get access to its vars
(require '[java.lang.instrument.Instrumentation :as inst])

; Find the size of an object
(println "The size of a map is"
         (inst/getObjectSize {:ts 20200101170000219 :bid 108.730000 :ask 108.786000})
         "bytes")

I have not used that Java library before, but note that many collections in Clojure are implemented using many Java objects, ie typically a "root" object that points to many other objects. 如果您想知道所有這些的大小,和/或創建顯示其結構的圖紙,我創建了一個名為cljol的庫,可以執行此操作: https://github.com/jafingerhut/cljol

自述文件顯示了使用示例以及您可以期待的 output。 頂層 README 中還有一個鏈接,指向使用該庫創建的其他圖像庫,用於一些 Clojure 數據結構。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM