测量dev/urandom的效率

3

作为一项任务,我需要测量/dev/urandom的效率。我的任务是:检查在1分钟内可以从/dev/urandom获取多少字节的数据。不要将已获取的数据写入磁盘,因为这可能会减慢整个过程。

我已经尝试过了。

timeout 60s cat /dev/urandom | wc -c

但我收到的只是一个“终止”的信息。
2个回答

3

添加--foreground选项:

timeout --foreground 60s cat /dev/urandom | wc -c

--foreground: 当不直接从shell提示符下运行timeout时,允许COMMAND从TTY读取并获取TTY信号;在此模式下,COMMAND的子进程将不会被超时


1

将您的命令分组:

$ { timeout 60s cat /dev/urandom; } | wc -c

但对我来说,60秒似乎有点长:

$ { timeout 1s cat /dev/urandom; } | wc -c
6160384                                     ### that's 6 Million bytes.

$ { timeout 10s cat /dev/urandom; } | wc -c
63143936                                    ### that's 63 Million bytes.


$ { timeout 10s cat /dev/urandom; } | wc -c
354844672                                   ### that's ~355 Million bytes.

但是最后一个度量指标受到计算机在那段时间内所做的任何事情的影响。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接