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.
Good day very cool site!! Man .. Beautiful ..
Superb .. I will bookmark your blog and take the feeds also?
I’m glad to seek out a lot of useful information here within the put
up, we need develop more strategies in this regard, thank
you for sharing. . . . . .
I take pleasure in, result in I found just what I
was having a look for. You’ve ended my 4 day lengthy
hunt! God Bless you man. Have a great day. Bye
An outstanding share! I have just forwarded this onto a coworker who was conducting a little
homework on this. And he in fact ordered me breakfast due to the fact that I stumbled upon it for him…
lol. So let me reword this…. Thank YOU for the meal!!
But yeah, thanks for spending the time to talk about this topic here on your blog.
It’s the best time to make some plans for the future and it is time to be
happy. I have read this post and if I could I wish to suggest you
few interesting things or suggestions. Maybe you can write next articles referring to this article.
I want to read more things about it!
Greetings! I know this is somewhat off topic but I was wondering which blog
platform are you using for this site? I’m getting fed up of WordPress because I’ve had issues with hackers and I’m looking at
options for another platform. I would be fantastic if you could
point me in the direction of a good platform.
Appreciation to my father who stated to me regarding this weblog, this blog is in fact awesome.
I do not even understand how I stopped up here, but I thought this publish was good.
I do not recognize who you’re however certainly you are going to a famous blogger when you
are not already. Cheers!
Hi there to all, how is all, I think every one is getting more
from this website, and your views are good in favor of
new users.
I visit each day a few blogs and information sites to read content, except this blog gives quality based posts.
Hey there! I’ve been following your blog for a while now and finally got the bravery to go ahead and give you
a shout out from Porter Texas! Just wanted to say keep up the excellent job!
Hi my family member! I want to say that this article is amazing, nice written and come with almost all significant
infos. I’d like to see extra posts like this .
Why viewers still make use of to read news papers
when in this technological world all is presented on web?
Very nice article. I certainly appreciate this website.
Stick with it!
Do you mind if I quote a couple of your posts as long as I provide credit and sources back to your
site? My blog site is in the exact same area of interest as yours and
my visitors would really benefit from some of the information you provide here.
Please let me know if this alright with you. Appreciate it!
I’ve read some just right stuff here. Definitely value bookmarking for revisiting.
I surprise how so much effort you set to create this type of magnificent informative website.
What a material of un-ambiguity and preserveness of precious familiarity regarding unexpected emotions.
Hey there! This post could not be written any better! Reading this post reminds me of my good old room mate!
He always kept talking about this. I will forward this post to
him. Pretty sure he will have a good read. Many thanks for sharing!
Ahaa, its fastidious conversation on the topic of this post here at this webpage,
I have read all that, so at this time me also commenting here.
Pretty element of content. I simply stumbled upon your weblog and in accession capital to say that I acquire actually enjoyed account your weblog posts.
Any way I’ll be subscribing for your feeds and even I success you get admission to
persistently quickly.
Great article! We will be linking to this great content on our website.
Keep up the great writing.
Hey just wanted to give you a brief heads up and let you know a few of the images aren’t loading properly.
I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.
Does your blog have a contact page? I’m having trouble locating
it but, I’d like to shoot you an email. I’ve got some ideas for your
blog you might be interested in hearing. Either way,
great website and I look forward to seeing it grow over time.
Hey very nice blog!
Hi there mates, how is everything, and what you wish for to say about this post, in my view its genuinely remarkable in support of me.
My partner and I stumbled over here coming from a different
page and thought I should check things out. I like what I see
so now i’m following you. Look forward to looking into your web page repeatedly.
Hi, I do believe this is a great web site.
I stumbledupon it ;) I will return yet again since i have book-marked it.
Money and freedom is the best way to change, may you
be rich and continue to help others.
After checking out a number of the blog articles on your web page, I truly like your technique of
writing a blog. I book marked it to my bookmark
site list and will be checking back soon. Please check out my website as well
and tell me your opinion.
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.
Wow, marvelous weblog format! How lengthy have you been blogging for?
you make blogging look easy. The whole look of your site
is wonderful, as neatly as the content material!
My family every time say that I am wasting my time here at web, but I know
I am getting knowledge every day by reading such nice articles or reviews.
I was wondering if you ever considered changing the structure of your
website? 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 two pictures.
Maybe you could space it out better?
Good day! This is my first comment here so I just wanted to give a quick shout
out and say I truly enjoy reading your blog posts. Can you suggest
any other blogs/websites/forums that deal with the same subjects?
Thanks a lot!
If some one desires expert view on the topic of blogging and site-building then i propose him/her to visit this
website, Keep up the nice work.
I blog frequently and I seriously thank you for your information.
The article has really peaked my interest. I’m going to bookmark your blog
and keep checking for new information about once a week.
I opted in for your RSS feed too.
Hey there! I realize this is somewhat off-topic but I had to ask.
Does running a well-established website like yours require a lot of work?
I am completely new to writing a blog however I do write in my diary everyday.
I’d like to start a blog so I will be able to share my own experience and thoughts online.
Please let me know if you have any kind of suggestions or tips for brand new aspiring
bloggers. Appreciate it!
What’s up, just wanted to mention, I loved this article. It was helpful.
Keep on posting!
If you would like to obtain a good deal from this article then you have to apply
these methods to your won website.
A motivating discussion is worth comment. There’s no doubt that that you need to write more on this topic,
it might not be a taboo matter but typically people don’t discuss these issues.
To the next! All the best!!
Woah! I’m really digging the template/theme of this website.
It’s simple, yet effective. A lot of times it’s very difficult to get that “perfect balance” between user friendliness and visual
appearance. I must say you have done a amazing job with this.
In addition, the blog loads super quick for me on Chrome.
Excellent Blog!
Your style is unique compared to other folks I have read stuff from.
I appreciate you for posting when you have the opportunity, Guess I will just book
mark this site.
Hi, I do believe this is a great site. I stumbledupon it ;) I will
revisit once again since i have book marked it.
Money and freedom is the best way to change, may you be rich and
continue to help other people.
My coder is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the expenses.
But he’s tryiong none the less. I’ve been using WordPress on a variety of websites for about a year and am anxious
about switching to another platform. I have heard excellent things about blogengine.net.
Is there a way I can transfer all my wordpress content into it?
Any help would be really appreciated!
Way cool! Some extremely valid points! I appreciate you writing this post and also the rest of the site is also very good.
Excellent pieces. Keep writing such kind of info on your page.
Im really impressed by it.
Hi there, You’ve performed an excellent job.
I’ll definitely digg it and in my opinion recommend to my friends.
I am confident they’ll be benefited from this website.
What i do not understood is in reality how you’re no longer
really a lot more smartly-appreciated than you may
be right now. You are very intelligent. You already
know thus significantly on the subject of this topic, produced me for my part consider
it from numerous various angles. Its like women and men are not fascinated except it is one thing to accomplish with Woman gaga!
Your individual stuffs outstanding. At all times care for it up!
Nice post. I was checking continuously this blog and I’m impressed!
Very useful info particularly the last part :) I care for such information a lot.
I was looking for this particular info for a very long time.
Thank you and best of luck.
Do you have a spam issue on this website; I also am a blogger, and I was wanting to know your situation; many of us have created some
nice procedures and we are looking to exchange solutions with other
folks, why not shoot me an email if interested.
I delight in, lead to I discovered just what I used to be taking
a look for. You have ended my four day lengthy hunt! God Bless you man. Have
a great day. Bye
Hi there, its good paragraph about media print, we all be aware of media is a great source of facts.
Having read this I thought it was very informative. I appreciate you finding the time and energy to put this information together.
I once again find myself personally spending a lot
of time both reading and commenting. But so what, it was still worth it!