mirror of
https://github.com/lionsoul2014/ip2region.git
synced 2025-12-08 19:25:22 +00:00
add cache-policy option desc
This commit is contained in:
parent
e59d71e316
commit
08a4ad245d
@ -98,10 +98,11 @@ make
|
||||
|
||||
通过 `xdb_searcher search` 命令来测试 ip2region.xdb 的查询:
|
||||
```
|
||||
➜ golang git:(v2.0_xdb) ✗ ./searcher search
|
||||
➜ golang git:(v2.0_xdb) ./xdb_searcher search
|
||||
./xdb_searcher search [command options]
|
||||
options:
|
||||
--db string ip2region binary xdb file path
|
||||
--db string ip2region binary xdb file path
|
||||
--cache-policy string cache policy: file/vectorIndex/content
|
||||
```
|
||||
|
||||
例如:使用默认的 data/ip2region.xdb 进行查询测试
|
||||
@ -112,18 +113,19 @@ ip2region>> 1.2.3.4
|
||||
{region:美国|0|华盛顿|0|谷歌, took:101.57µs}
|
||||
```
|
||||
|
||||
输入 ip 地址进行查询即可,输入 quit 退出测试程序。
|
||||
输入 ip 地址进行查询即可,输入 quit 退出测试程序。可以设置 `cache-policy` 为 vectorIndex 来测试缓存 VectorIndex 的查询,设置为 content 可以测试完全基于内存的查询方式。
|
||||
|
||||
|
||||
# bench 测试
|
||||
|
||||
通过 `xdb_searcher bench` 命令来进行自动 bench 测试,一方面确保程序和xdb文件都没有错误,一方面通过大量的查询得到平均查询性能:
|
||||
```bash
|
||||
➜ golang git:(v2.0_xdb) ✗ ./xdb_searcher bench
|
||||
➜ golang git:(v2.0_xdb) ./xdb_searcher bench
|
||||
./xdb_searcher bench [command options]
|
||||
options:
|
||||
--db string ip2region binary xdb file path
|
||||
--src string source ip text file path
|
||||
--db string ip2region binary xdb file path
|
||||
--src string source ip text file path
|
||||
--cache-policy string cache policy: file/vectorIndex/content
|
||||
```
|
||||
|
||||
例如:通过 data/ip2region.xdb 和 data/ip.merge.txt 进行 bench 测试:
|
||||
@ -132,4 +134,6 @@ options:
|
||||
Bench finished, {total: 3417955, took: 28.211578339s, cost: 8253 ns/op}
|
||||
```
|
||||
|
||||
可以设置 `cache-policy` 参数来测试 VectorIndex 和 content 缓存查询方式。
|
||||
|
||||
*请注意 bench 使用的 src 文件需要是生成对应的 xdb 文件的相同的源文件*。bench 程序会逐行读取 `src` 指定的源IP文件,然后每个 IP 段选取 5 个固定位置的 IP 进行测试,以确保查询的 region 信息和原始的 region 信息是相同。测试途中没有调试信息的输出,有错误会打印错误信息并且终止运行,所以看到 `Bench finished` 就表示 bench 成功了,cost 是表示每次查询操作的平均时间(ns)。
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user