tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: humanize_number(3) for dd(1) summary?



On 04.12.2010 17:54, Matt Thomas wrote:
> 
> On Dec 3, 2010, at 3:20 PM, Jean-Yves Migeon wrote:
> 
>> On 03.12.2010 23:46, Hubert Feyrer wrote:
>>> On Fri, 3 Dec 2010, Jean-Yves Migeon wrote:
>>>> 1073741824 bytes (1,0 GB) transferred in 15.701 secs (65 MB/sec)
>>>
>>> SUSv3[1]:
>>> ``On completion, dd shall write the number of input and output blocks to
>>> standard error. In the POSIX locale the following formats shall be used:
>>>
>>> "%u+%u records in\n", <number of whole input blocks>,
>>>    <number of partial input blocks>''
>>> - Hubert
>>>
>>> [1] http://www.opengroup.org/onlinepubs/009695399/toc.htm
>>
>> I am not touching the "records" lines, only the last one:
>>
>> $ ./dd if=/dev/zero of=/tmp/foobar bs=1024 count=3
>> 3+0 records in
>> 3+0 records out
>> 3072 bytes (3,0 KB) transferred in 0.001 secs (2,9 MB/sec)
>>
>> What am I missing?
> 
> I use dd to test performance and 2 digits of data is not neough.
> I actually like the current output.  I also support the idea if
> you want humanized numbers, a conv= option would be best.

I'll do as Christos suggested: leave the output as is, but implement a
msgfmt parameter where you can either:
- pass options:
        'msgfmt=human' (human readable output)
        'msgfmt=quiet' (silent mode -- if you don't care about output)
- pass a string format, similar to date(1) with strftime(3):
        msgfmt="%i records in\n%B bytes\nfoo %bar baz\n"

Default output will remain the same. Those that want to use dd(1) for
specific stuff like benchmarks or testing could use the msgfmt string to
tailor output to their liking.

-- 
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index