LINUX.ORG.RU

История изменений

Исправление firkax, (текущая версия) :

Что-то не похоже.

$ cd /run/user/1000
$ dd if=/dev/urandom of=randfile bs=1048576 count=100
$ cp randfile randfile1
$ time diff -q randfile randfile1 
real	0m0,109s
user	0m0,011s
sys	0m0,078s
$ time cmp randfile randfile1 
real	0m0,194s
user	0m0,038s
sys	0m0,067s
$ time cmp randfile randfile1 
real	0m0,145s
user	0m0,044s
sys	0m0,086s
$ time cmp randfile randfile1 
real	0m0,108s
user	0m0,028s
sys	0m0,079s
$ time diff -q randfile randfile1 
real	0m0,094s
user	0m0,017s
sys	0m0,070s
$ time diff -q randfile randfile1 
real	0m0,091s
user	0m0,017s
sys	0m0,069s
$ time diff -q randfile randfile1 
real	0m0,094s
user	0m0,012s
sys	0m0,075s
$ time cmp randfile randfile1 
real	0m0,120s
user	0m0,032s
sys	0m0,072s
$ time cmp randfile randfile1 
real	0m0,111s
user	0m0,027s
sys	0m0,077s

cmp даже медленнее в среднем на 20% почему-то. Теоретически разницы там быть не должно, обе команды должны делать тупо read() + memcmp().

Исходная версия firkax, :

Что-то не похоже.

$ cd /run/user/1000
$ dd if=/dev/urandom of=randfile bs=1048576 count=100
$ cp randfile randfile1
$ time diff -q randfile randfile1 
real	0m0,109s
user	0m0,011s
sys	0m0,078s
$ time cmp randfile randfile1 
real	0m0,194s
user	0m0,038s
sys	0m0,067s
$ time cmp randfile randfile1 
real	0m0,145s
user	0m0,044s
sys	0m0,086s
$ time cmp randfile randfile1 
real	0m0,108s
user	0m0,028s
sys	0m0,079s
$ time diff -q randfile randfile1 
real	0m0,094s
user	0m0,017s
sys	0m0,070s
$ time diff -q randfile randfile1 
real	0m0,091s
user	0m0,017s
sys	0m0,069s
$ time diff -q randfile randfile1 
real	0m0,094s
user	0m0,012s
sys	0m0,075s
$ time cmp randfile randfile1 
real	0m0,120s
user	0m0,032s
sys	0m0,072s
$ time cmp randfile randfile1 
real	0m0,111s
user	0m0,027s
sys	0m0,077s

cmp даже медленнее в среднем на 20% почему-то.