bench程序: 增加单个IP段,检查5个IP,与其它语言保持一致
This commit is contained in:
parent
f06e4b2544
commit
c6358117b4
|
|
@ -82,24 +82,40 @@ const main = async () => {
|
||||||
const rl = readline(src)
|
const rl = readline(src)
|
||||||
rl
|
rl
|
||||||
.on('line', async (line, lineCount, byteCount) => {
|
.on('line', async (line, lineCount, byteCount) => {
|
||||||
const list = line.split('|')
|
try {
|
||||||
const sip = list[0]
|
const list = line.split('|')
|
||||||
const eip = list[1]
|
const sip = list[0]
|
||||||
const sipInt = ipToInt(sip)
|
const eip = list[1]
|
||||||
const eipInt = ipToInt(eip)
|
const sipInt = ipToInt(sip)
|
||||||
|
const eipInt = ipToInt(eip)
|
||||||
|
|
||||||
const mipInt = Math.floor((sipInt + eipInt) / 2)
|
const mipInt = Math.floor((sipInt + eipInt) / 2)
|
||||||
const mip = intToIp(mipInt)
|
const mip = intToIp(mipInt)
|
||||||
|
|
||||||
const info = await searcher.search(mip)
|
const mipLeftInt = Math.floor((sipInt + mipInt) / 2)
|
||||||
|
const mipLeft = intToIp(mipLeftInt)
|
||||||
|
|
||||||
const region = list.slice(2, list.length).join('|')
|
const mipRightInt = Math.floor((mipInt + eipInt) / 2)
|
||||||
// check the region info
|
const mipRight = intToIp(mipRightInt)
|
||||||
if (region !== info.region) {
|
|
||||||
console.log(`failed search(${mip}) with (${region} != ${info.region})`)
|
const arr = [sip, mipLeft, mip, mipRight, eip]
|
||||||
|
|
||||||
|
for (let i = 0; i < arr.length; ++i) {
|
||||||
|
const target = arr[i]
|
||||||
|
const info = await searcher.search(target)
|
||||||
|
|
||||||
|
const region = list.slice(2, list.length).join('|')
|
||||||
|
// check the region info
|
||||||
|
if (region !== info.region) {
|
||||||
|
console.log(`failed search(${mip}) with (${region} != ${info.region})`)
|
||||||
|
process.exit(1)
|
||||||
|
}
|
||||||
|
total++
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.log(err)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
total++
|
|
||||||
})
|
})
|
||||||
.on('error', err => {
|
.on('error', err => {
|
||||||
console.log(err)
|
console.log(err)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue