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.
Thanks. Great stuff.
At this moment I am going away to do my breakfast, later than having my breakfast coming yet again to
read more news.
I visited various websites however the audio quality for audio songs current at this web site is genuinely fabulous.
Definitely consider that which you stated. Your favorite reason seemed to be at the internet the easiest thing to
understand of. I say to you, I definitely get irked whilst other folks think about concerns that
they just don’t recognise about. You controlled to hit the nail upon the highest and defined out
the whole thing without having side-effects
, folks could take a signal. Will probably be again to get more.
Thank you
An impressive share! I have just forwarded this onto a co-worker who
was conducting a little homework on this. And he in fact bought me breakfast due to the fact that
I discovered it for him… lol. So let me reword this…. Thank YOU for the meal!!
But yeah, thanks for spending the time to discuss this matter here
on your web page.
Wonderful web site. A lot of useful information here. I’m sending it to several friends ans additionally sharing in delicious.
And naturally, thank you on your sweat!
I needed to thank you for this great read!!
I certainly enjoyed every bit of it. I’ve got you saved as a favorite to check out new stuff you post…
Hi there to every single one, it’s actually a good for me to pay a quick visit this web
page, it includes helpful Information.
Its not my first time to pay a visit this web page, i am browsing this site dailly and get pleasant
data from here everyday.
Thanks on your marvelous posting! I certainly enjoyed reading it, you could be a great author.I
will always bookmark your blog and definitely will come back sometime
soon. I want to encourage one to continue your great job, have a nice evening!
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 site
when you could be giving us something enlightening to read?
Fantastic items from you, man. I have keep in mind your stuff previous to and you’re just too
wonderful. I actually like what you’ve received here, really like what you are saying and the best way
wherein you say it. You are making it entertaining and you continue to take care of
to stay it wise. I can not wait to learn much more from you.
This is actually a terrific site.
I think the admin of this web page is really working hard in support of his site,
as here every data is quality based data.
Have you ever thought about adding a little bit more than just your articles?
I mean, what you say is fundamental and everything. Nevertheless think of if you added some great visuals or videos to give your posts more,
“pop”! Your content is excellent but with images
and clips, this site could definitely be one of the greatest in its
niche. Great blog!
We are a group of volunteers and opening a new scheme in our community.
Your website provided us with valuable information to
work on. You have done an impressive job and our whole community will be thankful to you.
Unquestionably believe that which you stated. Your favorite justification appeared
to be on the net the simplest thing to be aware of.
I say to you, I certainly get annoyed while people consider worries that they just do not know
about. You managed to hit the nail upon the top and defined out the whole thing without having side-effects , people
can take a signal. Will probably be back to
get more. Thanks
of course like your web-site however you have to take
a look at the spelling on several of your posts.
Several of them are rife with spelling problems and I find it very troublesome to tell the truth however I will certainly come again again.
I am really pleased to read this website posts which
contains tons of useful data, thanks for providing these kinds of information.
If some one wishes to be updated with latest technologies therefore
he must be visit this website and be up to date every day.
Very great post. I just stumbled upon your blog and wanted to mention that I’ve really loved browsing your weblog posts.
In any case I’ll be subscribing on your feed and
I am hoping you write once more soon!
It’s really a cool and helpful piece of info. I’m glad that you just shared this useful information with us.
Please keep us up to date like this. Thanks for sharing.
I just couldn’t depart your web site prior to suggesting that I actually enjoyed the standard information a person supply for
your guests? Is going to be back steadily in order to investigate cross-check new posts
We absolutely love your blog and find a lot of your post’s to be exactly I’m looking
for. Would you offer guest writers to write content available
for you? I wouldn’t mind creating a post or elaborating on a lot of the subjects you write in relation to here.
Again, awesome weblog!
Saved as a favorite, I love your blog!
Nice post. I learn something new and challenging on websites I stumbleupon on a daily basis.
It’s always useful to read through content from other authors and use something from their sites.
Hi there, its good paragraph about media print, we all be aware of media is a fantastic source of data.
My relatives always say that I am killing my time
here at net, except I know I am getting experience everyday
by reading such fastidious articles or reviews.
This is really attention-grabbing, You’re a very skilled blogger.
I’ve joined your feed and stay up for searching for more of your fantastic post.
Additionally, I’ve shared your web site in my social networks
A person essentially assist to make critically posts I might state.
That is the very first time I frequented your web page and to
this point? I surprised with the research you made to make this particular
post extraordinary. Magnificent task!
Hello to all, how is all, I think every one is getting more
from this web site, and your views are good designed for new users.
I am in fact happy to glance at this website posts which consists of tons of helpful data, thanks for providing such data.
As the admin of this web page is working, no doubt very rapidly it will be famous,
due to its quality contents.
Great post. I used to be checking continuously this weblog and I am inspired!
Very helpful information particularly the last part :
) I deal with such info a lot. I used to be looking for this particular information for a long time.
Thanks and best of luck.
hello!,I really like your writing so much! proportion we keep in touch extra about your article on AOL?
I require a specialist on this house to resolve my problem.
Maybe that is you! Having a look ahead to see you.
I got this website from my buddy who shared with me concerning
this web site and at the moment this time I am visiting this site and reading very informative articles at this place.
Ridiculous story there. What happened after?
Good luck!
hello!,I love your writing so much! share
we communicate more about your post on AOL? I require an expert in this house to unravel
my problem. Maybe that is you! Taking a look ahead to peer you.
Please let me know if you’re looking for a article writer for your weblog.
You have some really good posts and I think I would be a good asset.
If you ever want to take some of the load off, I’d absolutely love to write some material for your blog in exchange for a link back to mine.
Please blast me an email if interested. Kudos!
Hurrah! In the end I got a website from where I
be able to in fact obtain valuable facts regarding my study and knowledge.
Hi to every one, for the reason that I am really eager of reading this
web site’s post to be updated on a regular basis. It includes nice data.
I could not refrain from commenting. Well written!
If some one needs to be updated with newest technologies afterward he must be pay a quick visit this website and be up to date
everyday.
I am no longer certain where you are getting your information, however great topic.
I needs to spend a while studying more or working out more.
Thank you for wonderful info I used to be on the lookout for this information for my mission.
I am really impressed together with your writing skills and
also with the layout in your blog. Is this a paid subject or did you
modify it yourself? Anyway stay up the excellent quality writing, it is uncommon to look a
nice weblog like this one nowadays..
Every weekend i used to pay a visit this
site, for the reason that i want enjoyment, for the reason that this this site conations in fact good
funny material too.
It’s an amazing post for all the internet users; they will take benefit from it I am sure.
Hello There. I found your blog using msn. This is an extremely well written article.
I will be sure to bookmark it and come back to
read more of your useful info. Thanks for the post. I’ll certainly return.
This post presents clear idea for the new people of blogging, that
genuinely how to do running a blog.
Have you ever thought about publishing an ebook or guest authoring
on other blogs? I have a blog centered on the same topics you discuss and would really like to have you share some stories/information. I know my readers would enjoy your work.
If you are even remotely interested, feel free to send me an e
mail.
Hi there! I could have sworn I’ve been to this website before
but after checking through some of the post I realized it’s new to me.
Anyhow, I’m definitely delighted I found it and I’ll
be bookmarking and checking back frequently!