14 KRK_Function(timeit) {
18 if (!
krk_parseArgs(
"V|i", (
const char *[]){
"callable",
"number"},
23 struct timeval tv_before, tv_after;
24 gettimeofday(&tv_before,NULL);
25 for (krk_integer_type t = 0; t < times; ++t) {
30 gettimeofday(&tv_after,NULL);
32 double before = (double)tv_before.tv_sec + (
double)tv_before.tv_usec / 1000000.0;
33 double after = (double)tv_after.tv_sec + (
double)tv_after.tv_usec / 1000000.0;
35 return FLOATING_VAL(after-before);
39 KRK_DOC(module,
"@brief Run functions very quickly without loop overhead from the interpreter.");
41 BIND_FUNC(module,timeit);
Struct definitions for core object types.
Stack reference or primative value.
Utilities for creating native bindings.
#define krk_parseArgs(f, n,...)
Parse arguments to a function while accepting keyword arguments.
#define KRK_DOC(thing, text)
Attach documentation to a thing of various types.
Definitions for primitive stack references.
Core API for the bytecode virtual machine.
krk_threadLocal KrkThreadState krk_currentThread
Thread-local VM state.
KrkValue krk_callStack(int argCount)
Call a callable on the stack with argCount arguments.
void krk_push(KrkValue value)
Push a stack value.