mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-18 21:29:19 +02:00
adding count to gc timer
This commit is contained in:
parent
8b46509ab5
commit
49505b4849
5 changed files with 21 additions and 3 deletions
|
@ -23,7 +23,9 @@
|
|||
(display msecs)
|
||||
(display " gc: ")
|
||||
(display gc-msecs)
|
||||
(newline)
|
||||
(display " (")
|
||||
(display (gc-count))
|
||||
(display " times)\n")
|
||||
(display "result: ")
|
||||
(write result)
|
||||
(newline)
|
||||
|
|
1
gc.c
1
gc.c
|
@ -483,6 +483,7 @@ sexp sexp_gc (sexp ctx, size_t *sum_freed) {
|
|||
getrusage(RUSAGE_SELF, &end);
|
||||
gc_usecs = (end.ru_utime.tv_sec - start.ru_utime.tv_sec) * 1000000 +
|
||||
end.ru_utime.tv_usec - start.ru_utime.tv_usec;
|
||||
++sexp_context_gc_count(ctx);
|
||||
sexp_context_gc_usecs(ctx) += gc_usecs;
|
||||
sexp_debug_printf("%p (freed: %lu max_freed: %lu finalized: %lu time: %luus)",
|
||||
ctx, (sum_freed ? *sum_freed : 0), sexp_unbox_fixnum(res),
|
||||
|
|
|
@ -469,7 +469,10 @@ struct sexp_struct {
|
|||
struct timeval tval;
|
||||
#endif
|
||||
char tailp, tracep, timeoutp, waitp, errorp;
|
||||
sexp_uint_t last_fp, gc_usecs;
|
||||
sexp_uint_t last_fp;
|
||||
#if SEXP_USE_TIME_GC
|
||||
sexp_uint_t gc_count, gc_usecs;
|
||||
#endif
|
||||
sexp stack, env, parent, child,
|
||||
globals, dk, params, proc, name, specific, event, result;
|
||||
#if SEXP_USE_DL
|
||||
|
@ -1102,7 +1105,13 @@ SEXP_API sexp sexp_make_unsigned_integer(sexp ctx, sexp_luint_t x);
|
|||
#define sexp_context_dk(x) (sexp_field(x, context, SEXP_CONTEXT, dk))
|
||||
#define sexp_context_params(x) (sexp_field(x, context, SEXP_CONTEXT, params))
|
||||
#define sexp_context_last_fp(x) (sexp_field(x, context, SEXP_CONTEXT, last_fp))
|
||||
#if SEXP_USE_TIME_GC
|
||||
#define sexp_context_gc_count(x) (sexp_field(x, context, SEXP_CONTEXT, gc_count))
|
||||
#define sexp_context_gc_usecs(x) (sexp_field(x, context, SEXP_CONTEXT, gc_usecs))
|
||||
#else
|
||||
#define sexp_context_gc_count(x) 0
|
||||
#define sexp_context_gc_usecs(x) 0
|
||||
#endif
|
||||
#define sexp_context_refuel(x) (sexp_field(x, context, SEXP_CONTEXT, refuel))
|
||||
#define sexp_context_ip(x) (sexp_field(x, context, SEXP_CONTEXT, ip))
|
||||
#define sexp_context_proc(x) (sexp_field(x, context, SEXP_CONTEXT, proc))
|
||||
|
|
|
@ -408,6 +408,10 @@ static sexp sexp_gc_op (sexp ctx, sexp self, sexp_sint_t n) {
|
|||
return sexp_make_unsigned_integer(ctx, sum_freed);
|
||||
}
|
||||
|
||||
static sexp sexp_gc_count_op (sexp ctx, sexp self, sexp_sint_t n) {
|
||||
return sexp_make_unsigned_integer(ctx, sexp_context_gc_count(ctx));
|
||||
}
|
||||
|
||||
static sexp sexp_gc_usecs_op (sexp ctx, sexp self, sexp_sint_t n) {
|
||||
return sexp_make_unsigned_integer(ctx, sexp_context_gc_usecs(ctx));
|
||||
}
|
||||
|
@ -651,6 +655,7 @@ sexp sexp_init_library (sexp ctx, sexp self, sexp_sint_t n, sexp env, const char
|
|||
sexp_define_foreign(ctx, env, "object-size", 1, sexp_object_size);
|
||||
sexp_define_foreign_opt(ctx, env, "integer->immediate", 2, sexp_integer_to_immediate, SEXP_FALSE);
|
||||
sexp_define_foreign(ctx, env, "gc", 0, sexp_gc_op);
|
||||
sexp_define_foreign(ctx, env, "gc-count", 0, sexp_gc_count_op);
|
||||
sexp_define_foreign(ctx, env, "gc-usecs", 0, sexp_gc_usecs_op);
|
||||
#if SEXP_USE_GREEN_THREADS
|
||||
sexp_define_foreign(ctx, env, "%set-atomic!", 1, sexp_set_atomic);
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
extend-env env-parent env-parent-set! env-lambda env-lambda-set!
|
||||
env-define! env-push! env-syntactic? env-syntactic?-set! core-code
|
||||
type-name type-cpl type-parent type-slots type-num-slots type-printer
|
||||
object-size integer->immediate gc gc-usecs atomically thread-list abort
|
||||
object-size integer->immediate gc gc-usecs gc-count
|
||||
atomically thread-list abort
|
||||
string-contains string-cursor-copy! errno integer->error-string
|
||||
flatten-dot update-free-vars! setenv unsetenv safe-setenv)
|
||||
(import (chibi))
|
||||
|
|
Loading…
Add table
Reference in a new issue