作为一项任务,我需要测量/dev/urandom的效率。我的任务是:检查在1分钟内可以从/dev/urandom获取多少字节的数据。不要将已获取的数据写入磁盘,因为这可能会减慢整个过程。
我已经尝试过了。
timeout 60s cat /dev/urandom | wc -c
但我收到的只是一个“终止”的信息。
添加--foreground
选项:
timeout --foreground 60s cat /dev/urandom | wc -c
--foreground
: 当不直接从shell提示符下运行timeout时,允许COMMAND从TTY读取并获取TTY信号;在此模式下,COMMAND的子进程将不会被超时
将您的命令分组:
$ { 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.