-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.ts
53 lines (48 loc) · 1.25 KB
/
common.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import { CborArray, CborObj, CborSimple, CborString, CborUInt } from "@harmoniclabs/cbor";
import { isObject } from "@harmoniclabs/obj-utils";
export interface BenchTermData {
size: number;
cpu: number;
mem: number;
// isError: boolean;
}
export function benchTermDataFromJson( stuff: any ): BenchTermData
{
if( !isObject( stuff ) )
{
return {
size: -1,
cpu: -1,
mem: -1,
// isError: true,
};
}
return {
size: typeof stuff.size === "number" ? stuff.size : -1,
cpu: typeof stuff.cpu === "number" ? stuff.cpu : -1,
mem: typeof stuff.mem === "number" ? stuff.mem : -1,
// isError: typeof stuff.isError === "boolean" ? stuff.isError : true,
};
}
export function benchTermDataToCbor({
size,
cpu,
mem,
// isError
}: BenchTermData ): CborObj
{
return new CborArray([
new CborUInt( size ),
new CborUInt( cpu ),
new CborUInt( mem ),
// new CborSimple( isError ),
]);
}
export interface BenchData {
matchMaybeJust: BenchTermData;
matchMaybeNothing: BenchTermData;
amountOf: BenchTermData[];
factorial: BenchTermData[];
fibonacci: BenchTermData[];
indexList: BenchTermData[];
}