
代码如下,使用了 pipeline,10W 数据执行下来要 2s,这个算是正常速度么?请问还有啥跑更快的办法么?
from datetime import datetime from redis import StrictRedis redis = StrictRedis(host='redis', port=6379, db=0) def test_redis(count): pipeline = redis.pipeline() process_start = datetime.now().timestamp() for value in range(1, count): user_key = 'user:id:' + str(value) pipeline.set(user_key, 'bar') pipeline.execute() process_elapsed = round(datetime.now().timestamp() - process_start, 2) print("\nDone ({}s).\n".format(process_elapsed)) test_redis(100000) 1 srx1982 Oct 6, 2021 换个解释器试试 |
2 superrichman Oct 6, 2021 Done (0.96s). 你可能需要内存超频 /doge |
3 Phishion OP @superrichman 感谢测试,我用的 VPS, 只能给啥用啥,你这个是挺快的 |
4 ynkkdev Oct 6, 2021 1.24s 来自普通办公笔记本 |
6 notyss Oct 7, 2021 你是想测试 redis 还是 python 还是 python 的 redis library |
7 zhchyu999 Oct 7, 2021 测试下 redis 的 redis-benchmark 测试下 redis 的性能,看看瓶颈在哪里 |