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);
38 KrkValue krk_module_onload_timeit(
void) {
42 KRK_DOC(module,
"@brief Run functions very quickly without loop overhead from the interpreter.");
44 BIND_FUNC(module,timeit);
47 return OBJECT_VAL(module);
Struct definitions for core object types.
KrkInstance * krk_newInstance(KrkClass *_class)
Create a new instance of the given class.
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.
KrkValue krk_callStack(int argCount)
Call a callable on the stack with argCount arguments.
#define vm
Convenience macro for namespacing.
KrkValue krk_pop(void)
Pop the top of the stack.
threadLocal KrkThreadState krk_currentThread
Thread-local VM state.
void krk_push(KrkValue value)
Push a stack value.