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.
bookmarked!!, I really like your site!
Howdy! I know this is kind of off topic but I was wondering which blog platform are you using for this website?
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 awesome if you could point me in the direction of a good platform.
I was able to find good advice from your blog articles.
Thanks for finally talking about > Day 16: Measure Performance Before Optimizing | Carlos Oliveira –
Optimization & Engineering < Loved it!
Hello there! This post could not be written much better!
Going through this article reminds me of my previous roommate!
He constantly kept preaching about this. I’ll send this article to him.
Fairly certain he’ll have a good read. Thanks for sharing!
Hello! This is kind of off topic but I need some guidance
from an established blog. Is it tough to set up your own blog?
I’m not very techincal but I can figure things out pretty
fast. I’m thinking about making my own but I’m not sure where to begin. Do
you have any points or suggestions? Cheers
Wow, this post is nice, my sister is analyzing these kinds of
things, thus I am going to convey her.
Oh my goodness! Incredible article dude! Thank you,
However I am having issues with your RSS. I don’t understand the reason why I can’t subscribe to
it. Is there anybody getting similar RSS issues? Anyone that knows the solution can you kindly
respond? Thanks!!
I’m gone to inform my little brother, that he should also
visit this blog on regular basis to get updated from hottest reports.
I was recommended this web site by my cousin. I am not sure whether this post is written by him as no one else know such detailed about my difficulty.
You’re amazing! Thanks!
Hello, after reading this amazing post i am also delighted to share my know-how here with mates.
This site was… how do you say it? Relevant!! Finally I have found something which helped me.
Many thanks!
Amazing! This blog looks exactly like my old one! It’s on a totally different topic but it has pretty much
the same layout and design. Excellent choice of colors!
Thanks for another excellent post. The place else may anybody get that type of info in such an ideal means of writing?
I have a presentation next week, and I am at the look for
such information.
Have you ever considered writing an ebook or guest authoring on other websites?
I have a blog centered on the same subjects you discuss and would love to have you share some stories/information. I know my
viewers would appreciate your work. If you’re even remotely interested, feel free to send me an email.
I absolutely love your website.. Pleasant colors & theme.
Did you build this site yourself? Please reply back as I’m planning to create my
own personal site and want to learn where you got
this from or what the theme is named. Thanks!
certainly like your website however you have to check the spelling
on quite a few of your posts. A number of them are rife with spelling issues and I to find it very bothersome to inform the
truth on the other hand I will certainly come again again.
My brother suggested I might like this website. He was entirely right.
This post truly made my day. You cann’t imagine just
how much time I had spent for this info! Thanks!
My spouse and I stumbled over here by a different page and thought I might check
things out. I like what I see so i am just following you.
Look forward to checking out your web page yet
again.
This excellent website definitely has all the info I needed about this subject and didn’t know
who to ask.
Appreciating the commitment you put into your site and in depth information you provide.
It’s good to come across a blog every once in a while that isn’t the same outdated rehashed information. Great read!
I’ve saved your site and I’m including your RSS feeds to my Google account.
If you wish for to take much from this article then you have to apply such methods to your won blog.
Incredible points. Solid arguments. Keep up the amazing spirit.
Hi there, I wish for to subscribe for this web site
to get most up-to-date updates, thus where can i do it please help out.
Having read this I thought it was rather informative.
I appreciate you spending some time and energy to put this information together.
I once again find myself personally spending a significant amount of time both reading and leaving comments.
But so what, it was still worthwhile!
Highly energetic article, I liked that bit.
Will there be a part 2?
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 two pictures.
Maybe you could space it out better?
Hi, I do think this is a great site. I stumbledupon it ;) I’m
going to revisit yet again since i have bookmarked it.
Money and freedom is the best way to change, may you be
rich and continue to guide other people.
We’re a group of volunteers and opening a new scheme in our community.
Your site offered us with valuable information to work
on. You’ve done a formidable job and our whole community will be grateful to you.
Fantastic post however I was wanting to know if you
could write a litte more on this subject? I’d be very grateful if you could elaborate a little bit further.
Many thanks!
Normally I do not learn post on blogs, but I would like to say that this write-up very forced me to take a look at and do it!
Your writing style has been amazed me. Thank you, very great
post.
A person essentially lend a hand to make critically articles I would state.
That is the first time I frequented your web page and to this point?
I surprised with the research you made to make this particular
put up extraordinary. Wonderful job!
What’s up friends, pleasant piece of writing and nice arguments commented here, I am
actually enjoying by these.
Hello, of course this piece of writing is genuinely fastidious and I have learned
lot of things from it about blogging. thanks.
Hi, i think that i saw you visited my site thus i came to “return the favor”.I am trying to find things to improve my web site!I suppose its ok to use a few of your ideas!!
Thanks for sharing your thoughts on rakurakulife-enjoy.com/vi-vn/ l?a ??o công an vi?t nam c?nh báo truy quét c?m g?p.
Regards
Today, while I was at work, my sister stole my iPad and tested to see if it can survive
a forty foot drop, just so she can be a youtube sensation. My iPad is now destroyed and she has 83 views.
I know this is totally off topic but I had to
share it with someone!
Thanks , I’ve just been searching for information about this subject for a while and yours
is the greatest I have came upon till now. However, what about the
bottom line? Are you sure concerning the source?
Good day! Would you mind if I share your blog with my myspace
group? There’s a lot of people that I think would really enjoy
your content. Please let me know. Thank you
Do you have any video of that? I’d want to find
out more details.
Hi to every body, it’s my first visit of this web site; this weblog contains remarkable and in fact excellent material for visitors.
I think this is one of the most significant
info for me. And i’m glad reading your article.
But wanna remark on few general things, The web site
style is perfect, the articles is really nice : D. Good job, cheers
Hi there, this weekend is good in support of me, for the reason that this moment i am reading this
fantastic informative paragraph here at my house.
I have learn a few just right stuff here. Certainly value bookmarking for revisiting.
I wonder how a lot attempt you put to make this kind of
excellent informative website.
Everything published was actually very logical.
However, think about this, suppose you added a little information?
I am not suggesting your content is not solid,
however suppose you added a headline to maybe get people’s
attention? I mean Day 16: Measure Performance Before Optimizing | Carlos Oliveira – Optimization & Engineering is kinda plain. You could glance at Yahoo’s home page and
see how they create post titles to grab people to click.
You might try adding a video or a picture or two to grab people excited about what you’ve got to say.
Just my opinion, it might bring your website a little livelier.
hi!,I love your writing so much! share we communicate
more about your article on AOL? I require a specialist in this space to
solve my problem. May be that is you! Having a look ahead
to see you.
Wow that was unusual. I just wrote an incredibly long comment but after I clicked submit my comment didn’t show up.
Grrrr… well I’m not writing all that over again. Anyhow, just wanted to say fantastic
blog!
Thank you for every other informative blog. Where else may I am
getting that kind of information written in such
an ideal method? I have a undertaking that I am just now operating on,
and I’ve been on the glance out for such info.
Howdy! I understand this is sort of off-topic but I had to ask.
Does running a well-established website like yours require a large amount of work?
I am completely new to operating a blog however I do write in my journal everyday.
I’d like to start a blog so I will be able to share my experience and
thoughts online. Please let me know if you have any kind of recommendations or tips for brand new aspiring
bloggers. Appreciate it!
Hey would you mind letting me know which webhost you’re working with?
I’ve loaded your blog in 3 different browsers and I must say this blog loads a lot quicker then most.
Can you recommend a good internet hosting provider at a honest price?
Cheers, I appreciate it!