34 lines
780 B
JavaScript
34 lines
780 B
JavaScript
let uidObj = {}
|
|
let uidArr = []
|
|
|
|
|
|
for (let i =0; i<100000000;i++) {
|
|
uidObj[i] = i
|
|
uidArr.push(100000+i)
|
|
}
|
|
|
|
console.log((new Date).getTime(), '对象开始查询')
|
|
console.log(uidObj['9999999999'], '对象结果')
|
|
console.log((new Date).getTime(), '对象查询完成,计算耗时')
|
|
|
|
console.log((new Date).getTime(), '数据填充完成,开始查询')
|
|
console.log(uidArr.find(function (item) {
|
|
return item == '999999999'
|
|
}), 'uid数组')
|
|
console.log((new Date).getTime(), '数据查询完成,计算耗时')
|
|
|
|
console.log(uidObj['9999'] ? 1 : 0, '111')
|
|
console.log(uidObj['dfsdf'] ? 1 : 0, 'dfdsfd')
|
|
|
|
// setInterval(function () {
|
|
// let index = Math.floor(Math.random() * 10000000 + 1)
|
|
// console.log(uidObj[index])
|
|
// }, 100)
|
|
|
|
|
|
|
|
|
|
|
|
// console.log(uidObj)
|
|
|