From cef917e57d590ba41b8f4c388e3a18cd07d36576 Mon Sep 17 00:00:00 2001 From: Vitaliy Artemov Date: Sun, 25 Feb 2024 18:35:27 +0000 Subject: [PATCH] clock: add declarations --- package-lock.json | 4 +-- package.json | 2 +- src/builtin/clock/Clock.d.ts | 61 ++++++++++++++++++++++++++++++++++++ src/builtin/index.d.ts | 1 - src/clock.d.ts | 1 + 5 files changed, 65 insertions(+), 4 deletions(-) create mode 100644 src/builtin/clock/Clock.d.ts create mode 100644 src/clock.d.ts diff --git a/package-lock.json b/package-lock.json index abb4b6b..3d6f765 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "tarantoolscript", - "version": "0.7.1", + "version": "0.8.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "tarantoolscript", - "version": "0.7.1", + "version": "0.8.0", "license": "MIT", "dependencies": { "@typescript-to-lua/language-extensions": "^1.19.0", diff --git a/package.json b/package.json index bdd6893..9df297f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "tarantoolscript", - "version": "0.7.1", + "version": "0.8.0", "author": "Vitaliy Artemov olivera507224@yandex.ru", "description": "TypeScript definitions for Tarantool Lua API.", "repository": { diff --git a/src/builtin/clock/Clock.d.ts b/src/builtin/clock/Clock.d.ts new file mode 100644 index 0000000..092309b --- /dev/null +++ b/src/builtin/clock/Clock.d.ts @@ -0,0 +1,61 @@ +/** @noSelfInFile */ + +import { CData } from 'builtin/box'; + +/** + * Get the wall clock time in seconds. + */ +export declare function time(): number; + +/** + * Get the wall clock time in seconds. + */ +export declare function realtime(): number; + +/** + * Get the wall clock time in nanoseconds. + */ +export declare function time64(): CData; + +/** + * Get the wall clock time in nanoseconds. + */ +export declare function realtime64(): CData; + +/** + * Get the monotonic time in seconds. + */ +export declare function monotonic(): number; + +/** + * Get the monotonic time in nanoseconds. + */ +export declare function monotonic64(): CData; + +/** + * Get the processor time in seconds. + */ +export declare function proc(): number; + +/** + * Get the processor time in nanoseconds. + */ +export declare function proc64(): CData; + +/** + * Get the thread time in seconds. + */ +export declare function thread(): number; + +/** + * Get the thread time in nanoseconds. + */ +export declare function thread64(): CData; + +/** + * Measure the time a function takes within a processor. + * @param func Function or function reference. + * @param args Whatever values are required by the function. + * @returns Table. First element – seconds of CPU time, second element – whatever the function returns. + */ +export declare function bench(func: (...args: U) => T, ...args: U): [number, T]; diff --git a/src/builtin/index.d.ts b/src/builtin/index.d.ts index b8eadd4..09234bd 100644 --- a/src/builtin/index.d.ts +++ b/src/builtin/index.d.ts @@ -1,5 +1,4 @@ /** @todo checks https://www.tarantool.io/en/doc/latest/reference/reference_lua/checks/ */ -/** @todo clock https://www.tarantool.io/en/doc/latest/reference/reference_lua/clock/ */ /** @todo compat https://www.tarantool.io/en/doc/latest/reference/reference_lua/compat/ */ /** @todo config https://www.tarantool.io/en/doc/latest/reference/reference_lua/config/ */ /** @todo console https://www.tarantool.io/en/doc/latest/reference/reference_lua/console/ */ diff --git a/src/clock.d.ts b/src/clock.d.ts new file mode 100644 index 0000000..b8d8360 --- /dev/null +++ b/src/clock.d.ts @@ -0,0 +1 @@ +export * from './builtin/clock/Clock';