• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Very fast and small Base64 Codec project at Source Forge

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks.
 
Mikael Grev
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Also a lot of performance charts is posted on the home page at:

http://migbase64.sourceforge.net/

Cheers,
Mikael
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic