UNPKG

6.54 kBTypeScriptView Raw
1declare class Benchmark {
2 static filter<T>(arr: T[], callback: (value: T) => any, thisArg?: any): T[];
3 static filter<T>(arr: T[], filter: string, thisArg?: any): T[];
4 static formatNumber(num: number): string;
5 static join(obj: Object, separator1?: string, separator2?: string): string;
6 static invoke(benches: Benchmark[], name: string | Object, ...args: any[]): any[];
7 static runInContext(context: Object): Function;
8
9 static each(obj: Object | any[], callback: Function, thisArg?: any): void;
10 static forEach<T>(arr: T[], callback: (value: T) => any, thisArg?: any): void;
11 static forOwn(obj: Object, callback: Function, thisArg?: any): void;
12 static has(obj: Object, path: any[] | string): boolean;
13 static indexOf<T>(arr: T[], value: T, fromIndex?: number): number;
14 static map<T, K>(arr: T[], callback: (value: T) => K, thisArg?: any): K[];
15 static reduce<T, K>(arr: T[], callback: (accumulator: K, value: T) => K, thisArg?: any): K;
16
17 static options: Benchmark.Options;
18 static platform: Benchmark.Platform;
19 static support: Benchmark.Support;
20 static version: string;
21
22 constructor(fn: Function | string, options?: Benchmark.Options);
23 constructor(name: string, fn: Function | string, options?: Benchmark.Options);
24 constructor(name: string, options?: Benchmark.Options);
25 constructor(options: Benchmark.Options);
26
27 id: number;
28 name?: string;
29 count: number;
30 cycles: number;
31 hz: number;
32 compiled: Function | string;
33 error: Error;
34 fn: Function | string;
35 aborted: boolean;
36 running: boolean;
37 setup: Function | string;
38 teardown: Function | string;
39
40 stats: Benchmark.Stats;
41 times: Benchmark.Times;
42
43 abort(): Benchmark;
44 clone(options: Benchmark.Options): Benchmark;
45 compare(benchmark: Benchmark): number;
46 emit(type: string | Object): any;
47 listeners(type: string): Function[];
48 off(type?: string, listener?: Function): Benchmark;
49 off(types: string[]): Benchmark;
50 on(type?: string, listener?: Function): Benchmark;
51 on(types: string[]): Benchmark;
52 reset(): Benchmark;
53 run(options?: Benchmark.Options): Benchmark;
54 toString(): string;
55}
56
57declare namespace Benchmark {
58 export interface Options {
59 async?: boolean | undefined;
60 defer?: boolean | undefined;
61 delay?: number | undefined;
62 id?: string | undefined;
63 initCount?: number | undefined;
64 maxTime?: number | undefined;
65 minSamples?: number | undefined;
66 minTime?: number | undefined;
67 name?: string | undefined;
68 onAbort?: Function | undefined;
69 onComplete?: Function | undefined;
70 onCycle?: Function | undefined;
71 onError?: Function | undefined;
72 onReset?: Function | undefined;
73 onStart?: Function | undefined;
74 setup?: Function | string | undefined;
75 teardown?: Function | string | undefined;
76 fn?: Function | string | undefined;
77 queued?: boolean | undefined;
78 }
79
80 export interface Platform {
81 description: string;
82 layout: string;
83 product: string;
84 name: string;
85 manufacturer: string;
86 os: string;
87 prerelease: string;
88 version: string;
89 toString(): string;
90 }
91
92 export interface Support {
93 browser: boolean;
94 timeout: boolean;
95 decompilation: boolean;
96 }
97
98 export interface Stats {
99 moe: number;
100 rme: number;
101 sem: number;
102 deviation: number;
103 mean: number;
104 sample: any[];
105 variance: number;
106 }
107
108 export interface Times {
109 cycle: number;
110 elapsed: number;
111 period: number;
112 timeStamp: number;
113 }
114
115 export class Deferred {
116 constructor(clone: Benchmark);
117
118 benchmark: Benchmark;
119 cycles: number;
120 elapsed: number;
121 timeStamp: number;
122
123 resolve(): void;
124 }
125
126 export interface Target {
127 options: Options;
128 async?: boolean | undefined;
129 defer?: boolean | undefined;
130 delay?: number | undefined;
131 initCount?: number | undefined;
132 maxTime?: number | undefined;
133 minSamples?: number | undefined;
134 minTime?: number | undefined;
135 name?: string | undefined;
136 fn?: Function | undefined;
137 id: number;
138 stats?: Stats | undefined;
139 times?: Times | undefined;
140 running: boolean;
141 count?: number | undefined;
142 compiled?: Function | undefined;
143 cycles?: number | undefined;
144 hz?: number | undefined;
145 }
146
147 export class Event {
148 constructor(type: string | Object);
149
150 aborted: boolean;
151 cancelled: boolean;
152 currentTarget: Object;
153 result: any;
154 target: Target;
155 timeStamp: number;
156 type: string;
157 }
158
159 export class Suite {
160 static options: { name: string };
161
162 constructor(name?: string, options?: Options);
163 constructor(options?: Options);
164
165 length: number;
166 aborted: boolean;
167 running: boolean;
168 name?: string;
169
170 abort(): Suite;
171 add(name: string, fn: Function | string, options?: Options): Suite;
172 add(fn: Function | string, options?: Options): Suite;
173 add(name: string, options?: Options): Suite;
174 add(options: Options): Suite;
175 clone(options: Options): Suite;
176 emit(type: string | Object): any;
177 filter(callback: Function | string): Suite;
178 join(separator?: string): string;
179 listeners(type: string): Function[];
180 off(type?: string, callback?: Function): Suite;
181 off(types: string[]): Suite;
182 on(type?: string, callback?: Function): Suite;
183 on(types: string[]): Suite;
184 push(benchmark: Benchmark): number;
185 reset(): Suite;
186 run(options?: Options): Suite;
187 reverse(): any[];
188 sort(compareFn: (a: any, b: any) => number): any[];
189 splice(start: number, deleteCount?: number): any[];
190 unshift(benchmark: Benchmark): number;
191
192 each(callback: Function): Suite;
193 forEach(callback: Function): Suite;
194 indexOf(value: any): number;
195 map(callback: Function | string): any[];
196 reduce<T>(callback: Function, accumulator: T): T;
197
198 pop(): Function;
199 shift(): Benchmark;
200 slice(start: number, end: number): any[];
201 slice(start: number, deleteCount: number, ...values: any[]): any[];
202 }
203}
204
205export = Benchmark;
206
\No newline at end of file