UNPKG

2.53 kBTypeScriptView Raw
1/* eslint-disable @typescript-eslint/no-explicit-any */
2declare module 'nodemark' {
3 class BenchmarkResult {
4 /** the average measured time in nanoseconds */
5 mean: number
6 /** the margin of error as a ratio of the mean */
7 error: number
8 /** the fastest measured time in nanoseconds */
9 max: number
10 /** the slowest measured time in nanoseconds */
11 min: number
12 /** the number of times the subject was invoked and measured */
13 count: number
14
15 /**
16 * Returns this.mean, rounded to the nearest whole number
17 * or the number of decimal places specified by `precision`
18 */
19 nanoseconds(precision?: number): number
20 /**
21 * Returns this.mean, rounded to the nearest whole number
22 * or the number of decimal places specified by `precision`
23 */
24 microseconds(precision?: number): number
25 /**
26 * Returns this.mean, rounded to the nearest whole number
27 * or the number of decimal places specified by `precision`
28 */
29 milliseconds(precision?: number): number
30 /**
31 * Returns this.mean, rounded to the nearest whole number
32 * or the number of decimal places specified by `precision`
33 */
34 seconds(precision?: number): number
35 /**
36 * Returns the average number of executions per second,
37 * rounded to the nearest whole number or the number of decimal places specified by precision.
38 */
39 hz(precision?: number): number
40 /**
41 * Returns the standard deviation per second,
42 * rounded to the nearest whole number or the number of decimal places specified by precision.
43 */
44 sd(precision?: number): number
45
46 /**
47 * Returns a nicely formatted string describing the result of the benchmark.
48 * By default, the "hz" format is used, which displays ops/sec,
49 * but you can optionally specify "nanoseconds", "microseconds", "milliseconds",
50 * or "seconds" to change the displayed information.
51 */
52 toString(
53 format?:
54 | 'hz'
55 | 'nanoseconds'
56 | 'microseconds'
57 | 'milliseconds'
58 | 'seconds',
59 ): string
60 }
61 const benchmark: {
62 (
63 subject: () => any,
64 setup?: () => any,
65 durationMillis?: number,
66 ): BenchmarkResult
67 (
68 subject: (callback: (...args: Array<unknown>) => void) => any,
69 setup?: () => any,
70 durationMillis?: number,
71 ): Promise<BenchmarkResult>
72 }
73 export = benchmark
74}
75
76declare module 'require-from-web' {
77 function requireFromWeb<T>(url: string): Promise<T>
78 export = requireFromWeb
79}
80
\No newline at end of file