|
@@ -1,32 +1,48 @@
|
|
|
# inplace Swap bytes
|
|
# inplace Swap bytes
|
|
|
|
|
|
|
|
-Echange d'octects 2 par 2 sur un fichier, en utilisant les _intrinsics_.
|
|
|
|
|
|
|
+Echange d'octets 2 par 2 sur un fichier, en utilisant les _intrinsics_.
|
|
|
|
|
|
|
|
|
|
|
|
|
Sur un fichier texte:
|
|
Sur un fichier texte:
|
|
|
-
|
|
|
|
|
```sh
|
|
```sh
|
|
|
echo '0123456789ABCDEF' > alpha
|
|
echo '0123456789ABCDEF' > alpha
|
|
|
./swap16 --input alpha
|
|
./swap16 --input alpha
|
|
|
Parsing: 17B.
|
|
Parsing: 17B.
|
|
|
Swab : 0.000 ms.
|
|
Swab : 0.000 ms.
|
|
|
cat alpha
|
|
cat alpha
|
|
|
-1023546798ABDCEF%
|
|
|
|
|
|
|
+1032547698BADCFE%
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
Sur un fichier plus épais:
|
|
Sur un fichier plus épais:
|
|
|
```sh
|
|
```sh
|
|
|
dd if=/dev/urandom of=/tmp/r.dummy bs=4M count=100
|
|
dd if=/dev/urandom of=/tmp/r.dummy bs=4M count=100
|
|
|
|
|
+
|
|
|
cp /tmp/r.dummy /tmp/r.true
|
|
cp /tmp/r.dummy /tmp/r.true
|
|
|
|
|
+
|
|
|
./swap16 --input /tmp/r.dummy
|
|
./swap16 --input /tmp/r.dummy
|
|
|
Parsing: 400M.
|
|
Parsing: 400M.
|
|
|
Swab : 46.875 ms.
|
|
Swab : 46.875 ms.
|
|
|
|
|
+
|
|
|
cmp /tmp/r.dummy /tmp/r.true
|
|
cmp /tmp/r.dummy /tmp/r.true
|
|
|
/tmp/r.dummy /tmp/r.true differ: char 1, line 1
|
|
/tmp/r.dummy /tmp/r.true differ: char 1, line 1
|
|
|
|
|
+
|
|
|
./swap16 --input /tmp/r.dummy
|
|
./swap16 --input /tmp/r.dummy
|
|
|
Parsing: 400M.
|
|
Parsing: 400M.
|
|
|
Swab : 46.875 ms.
|
|
Swab : 46.875 ms.
|
|
|
|
|
+
|
|
|
cmp /tmp/r.dummy /tmp/r.true
|
|
cmp /tmp/r.dummy /tmp/r.true
|
|
|
```
|
|
```
|
|
|
|
|
|
|
|
|
|
+comparison avec `dd`:
|
|
|
|
|
+```sh
|
|
|
|
|
+ dd if=/tmp/r.true of=/tmp/r.dd conv=swab
|
|
|
|
|
+819200+0 records in
|
|
|
|
|
+819200+0 records out
|
|
|
|
|
+419430400 bytes transferred in 0.501462 secs (836414929 bytes/sec)
|
|
|
|
|
+
|
|
|
|
|
+ cmp /tmp/r.dummy /tmp/r.dd
|
|
|
|
|
+
|
|
|
|
|
+```
|
|
|
|
|
+
|
|
|
|
|
+Notez que `dd` est beaucoup fois plus lent.
|
|
|
|
|
|