From d2eaaa0e1793c75c56f6fbfbdcf8b8aaa1dc47cb Mon Sep 17 00:00:00 2001 From: Enrico Tassi Date: Wed, 5 Apr 2006 13:23:39 +0000 Subject: [PATCH] added estimate_size --- components/extlib/hExtlib.ml | 4 ++++ components/extlib/hExtlib.mli | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/components/extlib/hExtlib.ml b/components/extlib/hExtlib.ml index 8a0c8cf7d..bf725122c 100644 --- a/components/extlib/hExtlib.ml +++ b/components/extlib/hExtlib.ml @@ -365,3 +365,7 @@ let raise_localized_exception ~offset floc exn = { flocb with Lexing.pos_cnum = x }, { floce with Lexing.pos_cnum = y } in raise (Localized (floc, exn)) + +let estimate_size x = + 4 * (String.length (Marshal.to_string x [])) / 1024 + diff --git a/components/extlib/hExtlib.mli b/components/extlib/hExtlib.mli index c41b2f94c..37a3bc6df 100644 --- a/components/extlib/hExtlib.mli +++ b/components/extlib/hExtlib.mli @@ -94,3 +94,7 @@ val floc_of_loc: int * int -> Token.flocation val dummy_floc: Lexing.position * Lexing.position val raise_localized_exception: offset:int -> Token.flocation -> exn -> 'a + +(* size in KB (SLOW) *) +val estimate_size: 'a -> int + -- 2.39.2