user3387666
user3387666

Reputation: 237

measure dev/urandom efficiency

I have to measure efficiency of /dev/urandom as an assignment. I've got the following task: Check, how many bytes of data you can get from /dev/urandom in 1 minute. Don't write taken data on disk, as it could slow everything down.

I've tried

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

But all I receive was just "Terminated" message.

Upvotes: 3

Views: 639

Answers (2)

user2350426
user2350426

Reputation:

Group your commands:

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

But 60 seconds seems to be on the high side to me:

$ { 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.

But the last measure is affected by anything the computer did in that period of time.

Upvotes: 1

Amadan
Amadan

Reputation: 198456

Add the --foreground option:

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

--foreground: when not running timeout directly from a shell prompt, allow COMMAND to read from the TTY and get TTY signals; in this mode, children of COMMAND will not be timed out

Upvotes: 3

Related Questions