Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Very fast and small Base64 Codec project at Source Forge

 
Mikael Grev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I've just uploaded a project to Source Forge. It's a Base64 Codec.

"MiGBase64 is a very fast and small Base64 Codec written in Java. It is currently faster than any other Java codecs I know of and it doesn't create any temporary arrays which many others do. 3-30x faster than Sun's and 2x faster than Commons Codec"

It's under BSD licence, so feel free to use it!

MiGBase64

Cheers,
Mikael Grev
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interesting. How did you actually get that kind of a performance boost compared to other implementations? And how are you avoiding the temporary arrays? By creating a big enough array in the beginning that you know won't need a resize?
 
Mikael Grev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I couple of smart tricks ;-). Basically moving ALL but the absolute necessary out of the main loop.

Temp array: When encoding the array is possibly to precalculate, for decoding I have a normal and a "fast" varsion. Both are "fast" though. the normal do a pre-scan to know the exact returned length and the "fast" version has to be fed with data that are somewhat well behaved:

From Javadoc:

+ The array must have a line length of 76 chars OR no line separators at all (one line).
+ Line separator must be "\r\n", as specified in RFC 2045
+ The array must not contain illegal characters within the encoded string
+ The array CAN have illegal characters at the beginning and end, those will be dealt with appropriately.<br>

ps. You can check out the source, it's only some 50 lines per encode/decode pair.

Cheers,
Mikael
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks.
 
Mikael Grev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Also a lot of performance charts is posted on the home page at:

http://migbase64.sourceforge.net/

Cheers,
Mikael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic