gpt4 book ai didi

redis - redis-cli --intrinsic-latency 中的纳秒不正确

转载 作者:可可西里 更新时间:2023-11-01 11:20:50 37 4
gpt4 key购买 nike

所以我运行这个命令:

$ redis-cli --intrinsic-latency 100 
... some lines ...

11386032 total runs (avg latency: 8.7827 microseconds / 87826.91 nanoseconds per run).
Worst run took 5064x longer than the average latency.

此报告中的问题是 87826.91 纳秒不等于 8.7827 微秒。
正确答案是 8782.69 纳秒

关于版本:

$ redis-cli -v      
redis-cli 3.0.5

$ redis-server -v
Redis server v=3.0.5 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=9e32aff68ca15a3f

最佳答案

在redis-cli.c中有这段代码:

static void intrinsicLatencyMode(void) {
.......
double avg_us = (double)run_time/runs;
double avg_ns = avg_us * 10e3;
if (force_cancel_loop || end > test_end) {
printf("\n%lld total runs "
"(avg latency: "
"%.4f microseconds / %.2f nanoseconds per run).\n",
runs, avg_us, avg_ns);
printf("Worst run took %.0fx longer than the average latency.\n",
max_latency / avg_us);
exit(0);
}

问题出在将微秒转换为纳秒的行中:

double avg_ns = avg_us * 10e3;

代码应该使用 1e3 而不是 10e3:

>gdb -q
(gdb) print 10e3
$1 = 10000
(gdb) print 1e3
$2 = 1000
(gdb)

关于redis - redis-cli --intrinsic-latency 中的纳秒不正确,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33982178/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com