deno.land / x / rambda@v9.1.1 / source / benchmarks / _utils.js

نووسراو ببینە
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
const fn1 = () => {}const fn2 = function (){}function fn3(){}
const listOfVariousTypes = [ new Boolean(true), true, new String('foobarbaz'), 'foo', 1, new Number(1), fn1, fn2, fn3, undefined, null, NaN, /foo/g, [ 1, 2, 3 ],]
const uniqListOfBooleans = limit => Array(limit) .fill(null) .map(() => [ Math.random() > 0.5, Math.random() > 0.5, Math.random() > 0.5, ])
const uniqListOfNumbers = limit => Array(limit) .fill(null) .map(() => Number(Math.floor(Math.random() * 1000)))const rangeOfNumbers = limit => Array(limit) .fill(null) .map((_, i) => i)
const uniqListOfStrings = limit => Array(limit) .fill(null) .map(() => String(Math.floor(Math.random() * 1000)))
const uniqListOfObjects = limit => Array(limit) .fill(null) .map(() => ({ foo : String(Math.floor(Math.random() * 1000)), bar : NaN, baz : null, qux : [ true ], }))
const uniqListOfLists = limit => Array(limit) .fill(null) .map(() => [ NaN, null, String(Math.floor(Math.random() * 1000)) ])
exports.uniqListOfBooleans = uniqListOfBooleansexports.uniqListOfNumbers = uniqListOfNumbersexports.uniqListOfStrings = uniqListOfStringsexports.uniqListOfObjects = uniqListOfObjectsexports.uniqListOfLists = uniqListOfListsexports.listOfVariousTypes = listOfVariousTypesexports.rangeOfNumbers = rangeOfNumbers
function* generatorFn(){ yield 1 yield 2 yield 3}
const setInstance = new Set([ 1, 2, 3, 4, 1 ])const weakSetInstance = new WeakSet()const weakMapInstance = new WeakMap()const mapInstance = new Map()
const target = { message1 : 'hello', message2 : 'everyone',}
const handler = {}
const proxyInstance = new Proxy(target, handler)weakSetInstance.add({ a : 1 })weakMapInstance.set({ a : 1 }, 'bar')mapInstance.set('foo', 'bar')
exports.variousTypes = [ -0, -Infinity, BigInt(9007199254740991), Date.now(), Infinity, Math.E, Symbol('foo'), generatorFn, mapInstance, new ArrayBuffer(8), new DataView(new ArrayBuffer(2)), new Error('bar'), new Int16Array(2), setInstance, proxyInstance, weakMapInstance, weakSetInstance,]const applyBenchmarkUnary = (fn, input) => { return fn(input)}const applyBenchmarkBinary = (fn, input) => { return fn(input[0], input[1])}const applyBenchmarkThreeInputs = (fn, input) => { return fn(input[0], input[1], input[2])}
exports.weakMapInstance = weakMapInstanceexports.mapInstance = mapInstanceexports.applyBenchmarkUnary = applyBenchmarkUnaryexports.applyBenchmarkBinary = applyBenchmarkBinaryexports.applyBenchmarkThreeInputs = applyBenchmarkThreeInputs
rambda

Version Info

Tagged at
a year ago