README.md in hexdump-0.2.4 vs README.md in hexdump-0.3.0

- old
+ new

@@ -1,9 +1,11 @@ -# hexdump +# hexdump.rb -* [Source](https://github.com/postmodern/hexdump) -* [Issues](https://github.com/postmodern/hexdump/issues) +[![CI](https://github.com/postmodern/hexdump.rb/actions/workflows/ruby.yml/badge.svg)](https://github.com/postmodern/hexdump.rb/actions/workflows/ruby.yml) + +* [Source](https://github.com/postmodern/hexdump.rb) +* [Issues](https://github.com/postmodern/hexdump.rb/issues) * [Documentation](http://rubydoc.info/gems/hexdump/frames) * [Email](mailto:postmodern.mod3 at gmail.com) ## Description @@ -13,12 +15,13 @@ * Can hexdump any Object supporting the `each_byte` method. * Can send the hexdump output to any Object supporting the `<<` method. * Can yield each line of hexdump, instead of printing the output. * Supports printing ASCII, hexadecimal, decimal, octal and binary bytes. -* Supports hexdumping 1, 2, 4, 8 byte words. -* Supports hexdumping Little and Big Endian words. +* Supports hexdumping bytes (8bit), words (16bit), double-words (32bit), and + quad-words (64bit). +* Supports Little Endian and Big Endian modes. * Makes {String}, {StringIO}, {IO}, {File} objects hexdumpable. * Fast-ish. ## Examples @@ -26,13 +29,15 @@ data = "hello\x00" Hexdump.dump(data) # 00000000 68 65 6c 6c 6f 00 |hello.| + # 00000006 data.hexdump # 00000000 68 65 6c 6c 6f 00 |hello.| + # 00000006 File.open('dump.txt','w') do |file| data.hexdump(:output => file) end @@ -40,108 +45,124 @@ data.hexdump do |index,hex,printable| index # => 0 hex # => ["68", "65", "6c", "6c", "6f", "00"] printable # => ["h", "e", "l", "l", "o", "."] end + # => 6 # configure the width of the hexdump - Hexdump.dump('A' * 30, :width => 10) + Hexdump.dump('A' * 30, width: 10) # 00000000 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAA| # 0000000a 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAA| # 00000014 41 41 41 41 41 41 41 41 41 41 |AAAAAAAAAA| + # 0000001e - Hexdump.dump(data, :ascii => true) + Hexdump.dump(data, ascii: true) # 00000000 h e l l o 00 |hello.| + # 00000006 - Hexdump.dump(data, :base => 16) + Hexdump.dump(data, base: 16) # 00000000 68 65 6c 6c 6f 00 |hello.| + # 00000006 - Hexdump.dump(data, :base => :decimal) + Hexdump.dump(data, base: :decimal) # 00000000 104 101 108 108 111 0 |hello.| + # 00000006 - Hexdump.dump(data, :base => :octal) + Hexdump.dump(data, base: :octal) # 00000000 0150 0145 0154 0154 0157 0000 |hello.| + # 00000006 - Hexdump.dump(data, :base => :binary) + Hexdump.dump(data, base: :binary) # 00000000 01101000 01100101 01101100 01101100 01101111 00000000 |hello.| + # 00000006 - ("ABC" * 10).hexdump(:word_size => 2) + ("ABC" * 10).hexdump(word_size: 2) # 00000000 4241 4143 4342 4241 4143 4342 4241 4143 |䉁䅃䍂䉁䅃䍂䉁䅃| # 00000010 4342 4241 4143 4342 4241 4143 4342 |䍂䉁䅃䍂䉁䅃䍂| + # 0000001e ## Install $ gem install hexdump ## Benchmarks -Benchmarks show {Hexdump.dump} processing 2.4M of data. +Benchmarks show {Hexdump.dump} processing 25M of data. -### Ruby 1.9.2-p180 +### Ruby 2.7.3 - user system total real - hexdump (block) 3.010000 0.010000 3.020000 ( 3.529396) - hexdump 5.430000 0.030000 5.460000 ( 6.216174) - hexdump width=256 (block) 3.010000 0.020000 3.030000 ( 3.308961) - hexdump width=256 4.700000 0.040000 4.740000 ( 5.520189) - hexdump ascii=true (block) 3.050000 0.010000 3.060000 ( 3.501436) - hexdump ascii=true 5.450000 0.040000 5.490000 ( 6.352144) - hexdump word_size=2 (block) 7.420000 0.050000 7.470000 ( 9.174734) - hexdump word_size=2 9.500000 0.070000 9.570000 ( 11.228204) - hexdump word_size=4 (block) 4.110000 0.030000 4.140000 ( 4.849785) - hexdump word_size=4 5.380000 0.060000 5.440000 ( 6.209022) - hexdump word_size=8 (block) 3.350000 0.070000 3.420000 ( 4.147304) - hexdump word_size=8 4.430000 0.040000 4.470000 ( 5.930758) +``` + user system total real +Hexdump.dump (output) 10.283433 0.000748 10.284181 ( 10.328899) +Hexdump.dump width=256 (output) 8.803228 0.005973 8.809201 ( 8.838375) +Hexdump.dump ascii=true (output) 10.740975 0.001903 10.742878 ( 10.779777) +Hexdump.dump word_size=2 (output) 15.163195 0.000989 15.164184 ( 15.220481) +Hexdump.dump word_size=4 (output) 14.279406 0.003840 14.283246 ( 14.345357) +Hexdump.dump word_size=8 (output) 7.715803 0.002879 7.718682 ( 7.746389) +Hexdump.dump (block) 5.543268 0.000980 5.544248 ( 5.561494) +Hexdump.dump width=256 (block) 5.438946 0.000000 5.438946 ( 5.455742) +Hexdump.dump ascii=true (block) 6.082787 0.000924 6.083711 ( 6.106234) +Hexdump.dump word_size=2 (block) 11.439610 0.000983 11.440593 ( 11.483788) +Hexdump.dump word_size=4 (block) 11.111633 0.000954 11.112587 ( 11.158416) +Hexdump.dump word_size=8 (block) 5.397569 0.002896 5.400465 ( 5.426971) +``` -### Ruby 1.8.7-p334 +### Ruby 3.0.1 - user system total real - hexdump (block) 8.470000 0.020000 8.490000 ( 9.585524) - hexdump 11.080000 0.050000 11.130000 ( 12.542401) - hexdump width=256 (block) 8.360000 0.030000 8.390000 ( 9.431877) - hexdump width=256 10.310000 0.050000 10.360000 ( 12.278973) - hexdump ascii=true (block) 8.550000 0.030000 8.580000 ( 10.502437) - hexdump ascii=true 11.140000 0.040000 11.180000 ( 12.752712) - hexdump word_size=2 (block) 12.680000 0.060000 12.740000 ( 14.657269) - hexdump word_size=2 13.560000 0.080000 13.640000 ( 16.368675) - hexdump word_size=4 (block) 8.500000 0.040000 8.540000 ( 9.687623) - hexdump word_size=4 9.340000 0.040000 9.380000 ( 10.657158) - hexdump word_size=8 (block) 7.520000 0.040000 7.560000 ( 8.565246) - hexdump word_size=8 8.240000 0.040000 8.280000 ( 9.475693) +``` + user system total real +Hexdump.dump (output) 12.064022 0.001165 12.065187 ( 12.118272) +Hexdump.dump width=256 (output) 10.228743 0.009920 10.238663 ( 10.279783) +Hexdump.dump ascii=true (output) 12.532913 0.000000 12.532913 ( 12.582665) +Hexdump.dump word_size=2 (output) 17.685782 0.000000 17.685782 ( 17.770686) +Hexdump.dump word_size=4 (output) 15.835564 0.000000 15.835564 ( 15.917552) +Hexdump.dump word_size=8 (output) 8.436831 0.000000 8.436831 ( 8.473445) +Hexdump.dump (block) 6.482589 0.000000 6.482589 ( 6.504816) +Hexdump.dump width=256 (block) 6.360828 0.000000 6.360828 ( 6.383705) +Hexdump.dump ascii=true (block) 6.911868 0.000000 6.911868 ( 6.936795) +Hexdump.dump word_size=2 (block) 13.120488 0.000000 13.120488 ( 13.179957) +Hexdump.dump word_size=4 (block) 12.349516 0.000000 12.349516 ( 12.412972) +Hexdump.dump word_size=8 (block) 5.814830 0.000000 5.814830 ( 5.837822) +``` -### JRuby 1.6.0 +### JRuby 9.2.16.0 - user system total real - hexdump (block) 6.742000 0.000000 6.742000 ( 6.495000) - hexdump 7.498000 0.000000 7.498000 ( 7.498000) - hexdump width=256 (block) 4.601000 0.000000 4.601000 ( 4.601000) - hexdump width=256 5.569000 0.000000 5.569000 ( 5.569000) - hexdump ascii=true (block) 5.198000 0.000000 5.198000 ( 5.198000) - hexdump ascii=true 5.799000 0.000000 5.799000 ( 5.798000) - hexdump word_size=2 (block) 8.440000 0.000000 8.440000 ( 8.440000) - hexdump word_size=2 8.698000 0.000000 8.698000 ( 8.698000) - hexdump word_size=4 (block) 5.603000 0.000000 5.603000 ( 5.602000) - hexdump word_size=4 5.999000 0.000000 5.999000 ( 5.999000) - hexdump word_size=8 (block) 7.975000 0.000000 7.975000 ( 7.975000) - hexdump word_size=8 5.255000 0.000000 5.255000 ( 5.255000) +``` + user system total real +Hexdump.dump (output) 13.090000 0.240000 13.330000 ( 11.226466) +Hexdump.dump width=256 (output) 9.350000 0.030000 9.380000 ( 9.165070) +Hexdump.dump ascii=true (output) 10.910000 0.050000 10.960000 ( 10.665791) +Hexdump.dump word_size=2 (output) 13.760000 0.150000 13.910000 ( 12.268307) +Hexdump.dump word_size=4 (output) 11.940000 0.090000 12.030000 ( 11.107564) +Hexdump.dump word_size=8 (output) 8.170000 0.040000 8.210000 ( 7.419708) +Hexdump.dump (block) 7.840000 0.020000 7.860000 ( 7.777749) +Hexdump.dump width=256 (block) 7.540000 0.000000 7.540000 ( 7.466315) +Hexdump.dump ascii=true (block) 7.680000 0.010000 7.690000 ( 7.622393) +Hexdump.dump word_size=2 (block) 9.830000 0.020000 9.850000 ( 9.693596) +Hexdump.dump word_size=4 (block) 9.010000 0.020000 9.030000 ( 8.998687) +Hexdump.dump word_size=8 (block) 5.740000 0.030000 5.770000 ( 5.709127) +``` -### Rubinius 1.2.4 +### TruffleRuby 21.0.0 - user system total real - hexdump (block) 5.064230 0.029996 5.094226 ( 6.236865) - hexdump 7.401875 0.039993 7.441868 ( 10.154394) - hexdump width=256 (block) 4.149369 0.054992 4.204361 ( 6.518306) - hexdump width=256 4.960246 0.089986 5.050232 ( 8.647516) - hexdump ascii=true (block) 4.458322 0.026996 4.485318 ( 5.570982) - hexdump ascii=true 6.961941 0.056992 7.018933 ( 9.895088) - hexdump word_size=2 (block) 8.856653 0.078988 8.935641 ( 11.226360) - hexdump word_size=2 10.489405 0.083988 10.573393 ( 12.980509) - hexdump word_size=4 (block) 4.848263 0.047992 4.896255 ( 6.526478) - hexdump word_size=4 6.649989 0.053992 6.703981 ( 8.245247) - hexdump word_size=8 (block) 5.638143 0.047993 5.686136 ( 12.530454) - hexdump word_size=8 7.598844 0.066990 7.665834 ( 16.881667) +``` + user system total real +Hexdump.dump (output) 25.818995 0.855689 26.674684 ( 22.376015) +Hexdump.dump width=256 (output) 20.489077 0.125966 20.615043 ( 18.301748) +Hexdump.dump ascii=true (output) 25.214678 0.098018 25.312696 ( 21.714985) +Hexdump.dump word_size=2 (output) 28.380387 0.192277 28.572664 ( 23.736887) +Hexdump.dump word_size=4 (output) 31.348977 0.134854 31.483831 ( 27.710968) +Hexdump.dump word_size=8 (output) 18.850093 0.100256 18.950349 ( 13.921720) +Hexdump.dump (block) 7.792878 0.050542 7.843420 ( 6.003789) +Hexdump.dump width=256 (block) 6.526531 0.015898 6.542429 ( 5.777169) +Hexdump.dump ascii=true (block) 7.425399 0.030799 7.456198 ( 5.705369) +Hexdump.dump word_size=2 (block) 12.629775 0.028653 12.658428 ( 11.115049) +Hexdump.dump word_size=4 (block) 20.372094 0.010807 20.382901 ( 19.758073) +Hexdump.dump word_size=8 (block) 8.828653 0.010889 8.839542 ( 8.017241) +``` ## Copyright -Copyright (c) 2011-2020 Hal Brodigan +Copyright (c) 2011-2021 Hal Brodigan See {file:LICENSE.txt} for details.