Commit 521b3540 authored by Juergen Nickelsen's avatar Juergen Nickelsen
Browse files

make (measure) without arguments count the time since start of the

interpreter (like the other measures), not since start of the epoch
parent 02ad5987
......@@ -517,6 +517,8 @@ obp_t bf_time(obp_t args, obp_t out_port, int level)
- (from.tv_sec * 1000000l + from.tv_usec));
}
struct timeval start_time;
obp_t bf_measure(obp_t args, obp_t out_port, int level)
{
struct timeval from;
......@@ -531,10 +533,13 @@ obp_t bf_measure(obp_t args, obp_t out_port, int level)
obp_t applys;
obp_t bindings;
obp_t objects;
obp_t result;
gettimeofday(&from, 0);
if (IS_NIL(args)) {
usecs = new_integer(from.tv_sec * 1000000l + from.tv_usec);
usecs = new_integer((from.tv_sec * 1000000l + from.tv_usec)
- (start_time.tv_sec * 1000000l
+ start_time.tv_usec));
evals = new_integer(eval_count);
applys = new_integer(apply_count);
bindings = new_integer(bind_count);
......@@ -555,13 +560,12 @@ obp_t bf_measure(obp_t args, obp_t out_port, int level)
bindings = new_integer(bind_count - start_bindings);
objects = new_integer(object_count - start_objects);
}
return cons(cons(get_symbol_z(USECS_NAME), usecs),
cons(cons(get_symbol_z(EVALS_NAME), evals),
cons(cons(get_symbol_z(APPLYS_NAME), applys),
cons(cons(get_symbol_z(BINDINGS_NAME), bindings),
cons(cons(get_symbol_z(OBJECTS_NAME), objects),
the_Nil)))));
result = cons(cons(get_symbol_z(OBJECTS_NAME), objects), the_Nil);
result = cons(cons(get_symbol_z(BINDINGS_NAME), bindings), result);
result = cons(cons(get_symbol_z(APPLYS_NAME), applys), result);
result = cons(cons(get_symbol_z(EVALS_NAME), evals), result);
result = cons(cons(get_symbol_z(USECS_NAME), usecs), result);
return result;
}
obp_t bf_funcall(obp_t args, obp_t out_port, int level)
......@@ -1029,6 +1033,8 @@ void init_builtins(void)
register_builtin(PRINCS_NAME, bf_princs, 0, 1, 2);
register_builtin(DESCRIBE_NAME, bf_describe, 0, 1, 2);
register_builtin(LENGTH_NAME, bf_length, 0, 1, 1);
gettimeofday(&start_time, 0);
}
/* EOF */
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment