我必须将/dev/urandom的效率度量为一项任务。我有以下任务:检查,您可以在1分钟内从/dev/urandom获取多少字节的数据。不要在磁盘上写入获取的数据,因为它会减慢所有的速度。
我试过了
timeout 60s cat /dev/urandom | wc -c但我收到的只是“终止”的信息。
发布于 2016-05-22 17:00:53
添加--foreground选项:
timeout --foreground 60s cat /dev/urandom | wc -c
--foreground:当不直接从shell提示符运行超时时,允许命令从TTY读取并获取TTY信号;在这种模式下,命令的子命令将不会超时。
发布于 2016-05-22 23:47:58
将命令分组:
$ { 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.但最后一项措施是受计算机在这段时间内所做的任何事情的影响。
https://stackoverflow.com/questions/37377063
复制相似问题