adding count to gc timer

This commit is contained in:
Alex Shinn 2015-06-27 20:43:43 +09:00
parent 8b46509ab5
commit 49505b4849
5 changed files with 21 additions and 3 deletions

View file

@ -23,7 +23,9 @@
(display msecs) (display msecs)
(display " gc: ") (display " gc: ")
(display gc-msecs) (display gc-msecs)
(newline) (display " (")
(display (gc-count))
(display " times)\n")
(display "result: ") (display "result: ")
(write result) (write result)
(newline) (newline)

1
gc.c
View file

@ -483,6 +483,7 @@ sexp sexp_gc (sexp ctx, size_t *sum_freed) {
getrusage(RUSAGE_SELF, &end); getrusage(RUSAGE_SELF, &end);
gc_usecs = (end.ru_utime.tv_sec - start.ru_utime.tv_sec) * 1000000 + gc_usecs = (end.ru_utime.tv_sec - start.ru_utime.tv_sec) * 1000000 +
end.ru_utime.tv_usec - start.ru_utime.tv_usec; end.ru_utime.tv_usec - start.ru_utime.tv_usec;
++sexp_context_gc_count(ctx);
sexp_context_gc_usecs(ctx) += gc_usecs; sexp_context_gc_usecs(ctx) += gc_usecs;
sexp_debug_printf("%p (freed: %lu max_freed: %lu finalized: %lu time: %luus)", sexp_debug_printf("%p (freed: %lu max_freed: %lu finalized: %lu time: %luus)",
ctx, (sum_freed ? *sum_freed : 0), sexp_unbox_fixnum(res), ctx, (sum_freed ? *sum_freed : 0), sexp_unbox_fixnum(res),

View file

@ -469,7 +469,10 @@ struct sexp_struct {
struct timeval tval; struct timeval tval;
#endif #endif
char tailp, tracep, timeoutp, waitp, errorp; 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, sexp stack, env, parent, child,
globals, dk, params, proc, name, specific, event, result; globals, dk, params, proc, name, specific, event, result;
#if SEXP_USE_DL #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_dk(x) (sexp_field(x, context, SEXP_CONTEXT, dk))
#define sexp_context_params(x) (sexp_field(x, context, SEXP_CONTEXT, params)) #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)) #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)) #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_refuel(x) (sexp_field(x, context, SEXP_CONTEXT, refuel))
#define sexp_context_ip(x) (sexp_field(x, context, SEXP_CONTEXT, ip)) #define sexp_context_ip(x) (sexp_field(x, context, SEXP_CONTEXT, ip))
#define sexp_context_proc(x) (sexp_field(x, context, SEXP_CONTEXT, proc)) #define sexp_context_proc(x) (sexp_field(x, context, SEXP_CONTEXT, proc))

View file

@ -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); 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) { 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)); 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(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_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", 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); sexp_define_foreign(ctx, env, "gc-usecs", 0, sexp_gc_usecs_op);
#if SEXP_USE_GREEN_THREADS #if SEXP_USE_GREEN_THREADS
sexp_define_foreign(ctx, env, "%set-atomic!", 1, sexp_set_atomic); sexp_define_foreign(ctx, env, "%set-atomic!", 1, sexp_set_atomic);

View file

@ -34,7 +34,8 @@
extend-env env-parent env-parent-set! env-lambda env-lambda-set! extend-env env-parent env-parent-set! env-lambda env-lambda-set!
env-define! env-push! env-syntactic? env-syntactic?-set! core-code env-define! env-push! env-syntactic? env-syntactic?-set! core-code
type-name type-cpl type-parent type-slots type-num-slots type-printer 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 string-contains string-cursor-copy! errno integer->error-string
flatten-dot update-free-vars! setenv unsetenv safe-setenv) flatten-dot update-free-vars! setenv unsetenv safe-setenv)
(import (chibi)) (import (chibi))