使用示例
以使用enwiki-latest-pages-articles类数据集为例进行KNewPfordelta接口性能测试。
配置数据集生成环境
- 请参见获取KNewPfordelta源代码获取KNewPfordelta接口源代码,测试框架代码位于源代码中。
- 请参见编译KNewPfordelta编译源代码。
- 安装Python3。
yum install python3 python3-devel python3-pip
- 安装conda。
- 安装Python模块。
conda install nltk numpy
- 安装nltk_data。
生成数据集
articles分类倒排索引数据集生成步骤。
- 从数据集下载articles分类的bz2格式公开wiki数据。例如:enwiki-latest-pages-articles1.xml-p1p41242.bz2。
https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles1.xml-p1p41242.bz2 https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles2.xml-p41243p151573.bz2 https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles3.xml-p151574p311329.bz2 https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles4.xml-p311330p558391.bz2 https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-pages-articles5.xml-p558392p958045.bz2
- 将下载的系列数据文件转换为Json文件。
cd /path/to/knewpfordelta/test/gen_data python parse_articles_xml.py enwiki-latest-pages-articles1.xml-p1p41242.bz2 enwiki-latest-pages-articles2.xml-p41243p151573.bz2 enwiki-latest-pages-articles3.xml-p151574p311329.bz2 enwiki-latest-pages-articles4.xml-p311330p558391.bz2 enwiki-latest-pages-articles5.xml-p558392p958045.bz2
- 将Json文件转换为字符集词频文件。
python export_terms_and_freq.py inverted_index_articles.json
- 将Json文件转换为文档ID二进制数据文件。
python rebuild_inverted_index_for_chunk.py inverted_index_articles.json
测试
- 解压缩测试。进入测试目录。
cd /path/to/knewpfordelta
- 性能测试。入参是词频率txt文件和二进制数据bin文件。
numactl -m 0 -c 0 ./newpfordelta_perf /path/to/term_list_articles.txt /path/to/doc_id_chunk_articles.bin
使用KNewPfordelta性能测试运行结果如下:
解压缩的速度speed指示了性能测试的情况。
- 功能测试。
numactl -m 0 -c 0 ./newpfordelta_ut /path/to/term_list_articles.txt /path/to/doc_id_chunk_articles.bin
功能测试运行结果如下:
回显信息中可以看到解压缩成功的提示信息。
- 性能测试。入参是词频率txt文件和二进制数据bin文件。
- 解压缩unpack函数及异常值性能测试。
- 清除生成文件。
make clean
- 编译KNewPfordelta。
make perf=1
- 性能测试。
numactl -m 0 -c 0 ./newpfordelta_perf /path/to/term_list_articles.txt /path/to/doc_id_chunk_articles.bin
使用KNewPfordelta性能测试运行结果如下:
运行结果展示了不同的解压缩unpack函数的正常值和异常值(Except)运行的时间,以及占unpack函数总运行时间的比例,Calls表示每个unpack函数被调用的次数。
- 清除生成文件。
父主题: KNewPfordelta接口说明