Amit’s Codebase

March 24, 2011

Efficiency.

Filed under: Java — amitcodes @ 7:20 am

I was writing code for Base64 encoder today. I was able to.
And then it occurred to me – “How about writing a function which can theoritically encode file of any arbitrary size.”

So I proceeded, to read bytes, encode them, write them to a file.
And then came in the second challenge – breaking the BIG base64 string into fixed-width lines (doesn’t sound challenging ? Try it!)
I was successful after burning out some brain cells.

But the joy of flexibility did not last long … read on to know why …

  • Target : encode 80 MB binary file.
  • My code takes 4.3 seconds (average)
  • GNU base64 took only 2.5 seconds
  • :-(

A lag of 1.8 seconds, not as efficient as ‘The Gurus’ …

Note: The programming language I used was Java. Say … how about trying out the same in Python ?? :)

Advertisement

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Theme: Shocking Blue Green. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.