More Lisps are supported:

--- a/src/interp/macros.lisp
+++ b/src/interp/macros.lisp
@@ -675,6 +675,17 @@ This function respects intermediate #\Newline characters and drops

 (defun WHOCALLED(n) nil) ;; no way to look n frames up the stack

+#+:sbcl
+(defun heapelapsed () (sb-ext:get-bytes-consed))
+#+:openmcl
+(defun heapelapsed () (ccl::total-bytes-allocated))
+#+:clisp
+(defun heapelapsed ()
+ (multiple-value-bind (used room static gc-count gc-space gc-time) (sys::%room)
+       (+ used gc-space)))
+#+:ecl
+(defun heapelapsed () (si::gc-stats t))
+#-(or :sbcl :openmcl :clisp :ecl)
 (defun heapelapsed () 0)

 (defun |goGetTracerHelper| (dn f oname alias options modemap)

- Qian

On 10/15/23 18:04, Qian Yun wrote:
The support for collecting and reporting memory usage is already there,
just missing a few pieces.

After applying this patch, this functionality can be enabled by:
     )boot $printStorageIfTrue := true

Not all lisps support this, so I wonder if this option should
be visible under ")set message time".

- Qian

=====

diff --git a/src/interp/g-timer.boot b/src/interp/g-timer.boot
index 501092e2..61febdf4 100644
--- a/src/interp/g-timer.boot
+++ b/src/interp/g-timer.boot
@@ -79,12 +79,7 @@ normalizeStatAndStringify t ==
        t := roundStat t
        t = 0.0 => '"0"
        FORMAT(nil,'"~,2F",t)
-  INTEGERP t =>
-      K := 1024
-      M := K*K
-      t > 9*M => CONCAT(STRINGIMAGE((t + 512*K)/M), '"M")
-      t > 9*K => CONCAT(STRINGIMAGE((t + 512)/K),   '"K")
-      STRINGIMAGE t
+  INTEGERP t => FORMAT(nil, '"~:d", t)
    STRINGIMAGE t

  significantStat t ==
@@ -171,6 +166,7 @@ initializeTimedNames(listofnames,listofclasses) ==
      PUT( name, 'ClassSpaceTotal,  0)
    $timedNameStack := '(other)
    computeElapsedTime()
+  computeElapsedSpace()
    PUT('gc, 'TimeTotal, 0.0)
    PUT('gc, 'SpaceTotal,  0)
    NIL
@@ -178,6 +174,8 @@ initializeTimedNames(listofnames,listofclasses) ==
  updateTimedName name ==
    count := (GET(name, 'TimeTotal) or 0) + computeElapsedTime()
    PUT(name, 'TimeTotal, count)
+  count := (GET(name, 'SpaceTotal) or 0) + computeElapsedSpace()
+  PUT(name, 'SpaceTotal, count)

  makeLongTimeString(listofnames,listofclasses) ==
    makeLongStatStringByProperty(listofnames, listofclasses,  _
@@ -236,9 +234,6 @@ timedEvaluate code ==
      "append"/[eval ["LIST",:x] for x in splitIntoBlocksOf200 a]
    eval code

-displayHeapStatsIfWanted() ==
-   $printStorageIfTrue => sayBrightly OLDHEAPSTATS()
-
  --% stubs for the stats summary fns
  statRecordInstantiationEvent() == nil
  statRecordLoadEvent()          == nil
diff --git a/src/interp/macros.lisp b/src/interp/macros.lisp
index d24589f8..1be5f3b2 100644
--- a/src/interp/macros.lisp
+++ b/src/interp/macros.lisp
@@ -675,6 +675,11 @@ This function respects intermediate #\Newline characters and drops

  (defun WHOCALLED(n) nil) ;; no way to look n frames up the stack

+#+:sbcl
+(defun heapelapsed () (sb-ext:get-bytes-consed))
+#+:openmcl
+(defun heapelapsed () (ccl::total-bytes-allocated))
+#-(or :sbcl :openmcl)
  (defun heapelapsed () 0)

  (defun |goGetTracerHelper| (dn f oname alias options modemap)

--
You received this message because you are subscribed to the Google Groups "FriCAS - 
computer algebra system" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to fricas-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/fricas-devel/66cda359-6e93-4e20-8912-4aa6efe2db5b%40gmail.com.

Reply via email to