Day 16: Measure Performance Before Optimizing
Writing programs takes time, but writing correct and fast programs is even more difficult. That is why there is so much badly written software in the market. Bugs are the result of sloppy and rushed code. Programs are frequently slower than they need to be as a result.
In this situation, it sometimes seems smart to design systems that are efficient. But for many programmers, efficiency becomes an end in itself, and they end up trying to optimize code before understanding the real implications of these optimizations.
One of the most common problems is not understanding the real bottlenecks in the system. For example, when writing software for the web using standard architectures, accessing the data base is frequently the bottleneck of the system. When faced with this situation, it doesn’t matter if the code to handle string comparison is written in assembly or in Ruby, the result will be approximately the same.
Measuring Speed Up
There is an interesting result studied in computer architechture called the Ahmdal Law. This principle says that any optimization (say, getting twice the performance) applied to a part of the system that is responsible for only a small percentage of the execution time will result in a very small improvement.
For example, suppose that you improve the string handling code to be 10 times more efficient. This might give you hopes that the whole system will be a few times more efficient that it is. However, after measuring the system, you verify that the time spent on string comparison is 10% of the total time.
The result is that an operation that takes 10% of the total time now takes only 1% of the time. However, this means that the performance improvement for the whole system is just 9%.
If 9% still seems good for you, notice that I was very generous here. It is really hard to change something to be 10 times faster, unless you come up with a different algorithm. Also, the differences in percentage of usage are not commonly in the range 10 to 90%, but more frequently it is 1 to 99%. That is, most areas of your code contribute 1% or less to the running time, while bottlenecks such as network and database delays are responsible for 99% of the time.
Even for processor bound tasks this situation remains. There is probably a few small parts of your code that are responsible for 99% of the time spent in the program.
That is why measuring a system is so important. If you don’t know what is responsible for that figure of 99%, your efforts to improve the performance of the system are basicaly wasted. You should aim first at understanding what contributes to the bottlenecks in the system. Then, you can start planning on how to improve that area.
Further Reading
Read Computer Architecture: A Quantitative Approach to find everything you may want to know about Amdahl Law and how it applies to computer systems.
Ahaa, its nice dialogue on the topic of this article here at
this webpage, I have read all that, so at this time me also commenting here.
Hey I know this is off topic but I was wondering if you knew of any widgets I could add to my blog that automatically tweet my newest twitter updates.
I’ve been looking for a plug-in like this for quite some time and was hoping maybe you would have
some experience with something like this. Please
let me know if you run into anything. I truly enjoy reading your blog and I look forward to
your new updates.
It’s in point of fact a great and useful piece of information.
I’m satisfied that you simply shared this useful information with us.
Please stay us informed like this. Thanks for sharing.
Hi there! I could have sworn I’ve been to this website before but after browsing through some of the post
I realized it’s new to me. Anyhow, I’m definitely
happy I found it and I’ll be bookmarking and checking back often!
We are a gaggle of volunteers and opening a brand new scheme in our community.
Your site offered us with useful information to
work on. You have done a formidable job and our entire
neighborhood will likely be grateful to you.
I was curious if you ever considered changing the layout of your blog?
Its very well written; I love what youve got to say.
But maybe you could a little more in the way of content so
people could connect with it better. Youve got an awful lot of text for only having 1 or 2 images.
Maybe you could space it out better?
I have been browsing online more than 4 hours today, yet I never found any interesting article like yours.
It’s pretty worth enough for me. In my view, if all webmasters and bloggers made good content as you did, the web will be
much more useful than ever before.
Thanks very nice blog!
Can you tell us more about this? I’d love to find out more
details.
I know this site presents quality depending articles or reviews and additional data,
is there any other website which provides these kinds of stuff in quality?
It’s remarkable to visit this site and reading
the views of all colleagues concerning this article, while I am also eager of getting experience.
That is a really good tip especially to those new to the blogosphere.
Simple but very accurate info… Thank you for sharing this one.
A must read post!
I wanted to thank you for this wonderful read!! I certainly loved every bit
of it. I have you book-marked to check out new stuff
you post…
Hi outstanding website! Does running a blog such as this take a lot of work?
I’ve absolutely no knowledge of programming however I was hoping to start my
own blog soon. Anyhow, should you have any suggestions or
tips for new blog owners please share. I understand this is off topic nevertheless I just wanted to ask.
Cheers!
Currently it seems like Drupal is the best blogging platform
out there right now. (from what I’ve read) Is that what you are using on your blog?
Hello very cool web site!! Guy .. Beautiful ..
Amazing .. I will bookmark your web site and take the feeds additionally?
I am happy to search out a lot of helpful information here within the submit, we
want develop extra techniques in this regard,
thanks for sharing. . . . . .
Hi there, this weekend is fastidious designed for me, because this point in time i am reading this impressive
educational paragraph here at my home.
The other day, while I was at work, my sister stole my iphone
and tested to see if it can survive a 30 foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views.
I know this is completely off topic but I had to share it with someone!
Wonderful beat ! I would like to apprentice while you amend your web site, how could i subscribe for a blog website?
The account helped me a acceptable deal. I had been tiny bit
acquainted of this your broadcast provided bright clear idea
For most recent news you have to go to see world wide web and on web I found this web page as
a finest web site for newest updates.
Hi colleagues, nice piece of writing and fastidious
urging commented here, I am actually enjoying by these.
Oh my goodness! Awesome article dude! Thank
you so much, However I am encountering issues with your
RSS. I don’t know why I can’t subscribe to it. Is there anyone else getting similar RSS issues?
Anybody who knows the solution will you kindly respond?
Thanx!!
I am really impressed with your writing skills
as well as with the layout on your weblog. Is this a paid theme or did you customize it yourself?
Either way keep up the nice quality writing, it’s rare to
see a great blog like this one nowadays.
Terrific post but I was wondering if you could
write a litte more on this topic? I’d be very thankful if you could elaborate a little bit further.
Bless you!
It’s remarkable for me to have a website, which is good designed for my know-how.
thanks admin
Hmm it appears like your website ate my first comment (it was extremely long) so I guess I’ll just sum it up what I had written and say, I’m thoroughly enjoying your blog.
I as well am an aspiring blog blogger but I’m still
new to the whole thing. Do you have any recommendations for first-time blog writers?
I’d genuinely appreciate it.
I think the admin of this site is actually working hard in favor of his website, since here every data is quality based stuff.
I truly love your website.. Excellent colors & theme. Did you develop this website yourself?
Please reply back as I’m attempting to create my own site and would love to find out where you got
this from or what the theme is named. Thank you!
It’s remarkable in favor of me to have a site,
which is good in favor of my knowledge. thanks admin
When I originally commented I appear to have clicked
the -Notify me when new comments are added- checkbox
and from now on each time a comment is added I
recieve 4 emails with the exact same comment.
Perhaps there is an easy method you are able to remove me from
that service? Appreciate it!
Way cool! Some extremely valid points! I appreciate
you writing this article and also the rest of the site is also very good.
Hello, i believe that i noticed you visited my site so i came to return the want?.I’m attempting to find issues to enhance my site!I guess
its ok to make use of some of your concepts!!
Hey! Would you mind if I share your blog with my twitter group?
There’s a lot of people that I think would really appreciate your content.
Please let me know. Many thanks
Very nice post. I just stumbled upon your weblog and wanted to mention that
I’ve truly enjoyed surfing around your weblog
posts. In any case I will be subscribing for your feed and I am hoping you write once more very soon!
I blog quite often and I genuinely appreciate your content.
This article has really peaked my interest. I’m going
to book mark your site and keep checking for new information about once a week.
I opted in for your RSS feed as well.
Thank you for the good writeup. It actually was once a enjoyment account it.
Glance complicated to far delivered agreeable from you!
By the way, how can we be in contact?
Exceptional post however I was wondering if you could
write a litte more on this topic? I’d be very thankful if
you could elaborate a little bit further. Cheers!
whoah this weblog is magnificent i love studying your articles.
Stay up the great work! You realize, many persons are searching round
for this information, you could aid them greatly.
Hey there! I know this is kind of off topic but I was wondering which
blog platform are you using for this website? I’m getting sick and tired of WordPress because I’ve had issues with hackers and
I’m looking at alternatives for another platform.
I would be great if you could point me in the direction of a good platform.
Woah! I’m really enjoying the template/theme of this site.
It’s simple, yet effective. A lot of times it’s hard
to get that “perfect balance” between superb usability and visual appearance.
I must say that you’ve done a amazing job with this.
Additionally, the blog loads extremely quick for me on Firefox.
Excellent Blog!
I like it when people get together and share ideas.
Great website, keep it up!
Greetings I am so thrilled I found your webpage, I really found
you by accident, while I was looking on Yahoo for something else, Anyways I am here
now and would just like to say kudos for a marvelous post and a all round exciting blog (I also love the theme/design),
I don’t have time to look over it all at the moment but I have book-marked it and also included
your RSS feeds, so when I have time I will be back to read
much more, Please do keep up the great b.
What’s up, I read your blogs like every week. Your
story-telling style is awesome, keep doing what you’re doing!
I have read so many content about the blogger lovers however this
paragraph is actually a fastidious paragraph, keep it up.
Awesome post.
Thank you, I’ve just been looking for info approximately this subject for a while and yours is the best I’ve found out so far.
But, what concerning the conclusion? Are you certain in regards to the supply?
Write more, thats all I have to say. Literally,
it seems as though you relied on the video to make your point.
You definitely know what youre talking about, why throw away your intelligence on just
posting videos to your weblog when you could be giving us
something enlightening to read?
There’s definately a lot to find out about this topic. I love all the points you made.
I’m not sure exactly why but this weblog is loading incredibly slow for me.
Is anyone else having this problem or is it a issue on my end?
I’ll check back later and see if the problem still
exists.
Hi Dear, are you truly visiting this website daily, if so then you will
absolutely obtain nice experience.