测量开发/随机效率

时间:2016-05-22 16:55:47

标签: linux bash random

我必须测量/ dev / urandom的效率作为赋值。我有以下任务:检查,你可以在1分钟内从/ dev / urandom获得多少字节的数据。不要在磁盘上写入数据,因为它可能会减慢所有内容。

我试过

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

但我收到的只是“终止”消息。

2 个答案:

答案 0 :(得分:3)

添加--foreground选项:

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

--foreground:当没有直接从shell提示符运行超时时,允许COMMAND从TTY读取并获取TTY信号;在这种模式下,COMMAND的孩子不会超时

答案 1 :(得分: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.

但是最后一项措施会受到计算机在那段时间内所做的任何事情的影响。

相关问题