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.
Howdy! Someone in my Myspace group shared this site with
us so I came to take a look. I’m definitely loving the information. I’m bookmarking and
will be tweeting this to my followers! Fantastic blog and wonderful design and style.
Everyone loves it when people get together and share thoughts.
Great website, stick with it!
Hello there! Would you mind if I share your blog with my zynga group?
There’s a lot of people that I think would really appreciate your content.
Please let me know. Thanks
I am in fact delighted to read this weblog posts which consists
of plenty of valuable data, thanks for providing such
data.
Yes! Finally someone writes about Burlap kippah.
Wonderful article! We are linking to this great content on our site.
Keep up the good writing.
I all the time emailed this website post page
to all my associates, for the reason that if like to read it after that my
contacts will too.
For hottest information you have to pay a visit the web and
on world-wide-web I found this website as a finest web site for most recent updates.
You should be a part of a contest for one of the finest websites on the web.
I am going to recommend this web site!
Undeniably believe that which you said. Your favorite justification seemed to be on the internet the easiest thing to be aware of.
I say to you, I certainly get irked while people consider worries that they just do not know about.
You managed to hit the nail upon the top as well as defined
out the whole thing without having side-effects ,
people can take a signal. Will probably be back to get more.
Thanks
I think this is among the most significant info for me.
And i’m glad reading your article. But want to remark on few general things, The web site style is
great, the articles is really nice : D. Good job, cheers
There is definately a great deal to find out about this issue.
I like all the points you made.
This article will assist the internet viewers for creating new blog or
even a blog from start to end.
This is really interesting, You’re a very skilled blogger.
I have joined your rss feed and look forward to seeking more of your great post.
Also, I have shared your web site in my social networks!
Please let me know if you’re looking for
a author for your weblog. You have some really great posts and I think I would be a good asset.
If you ever want to take some of the load off, I’d love to write some content for your blog in exchange for a link back to mine.
Please blast me an email if interested. Thank you!
Hey There. I found your blog using msn. This is an extremely
well written article. I will make sure to bookmark it and return to read more of your useful information. Thanks for the post.
I’ll definitely return.
Hello! This is my first comment here so I just wanted to
give a quick shout out and tell you I genuinely enjoy reading through your articles.
Can you recommend any other blogs/websites/forums that go over the same subjects?
Thanks a lot!
It’s very effortless to find out any topic on net as compared to books, as I found this article at this website.
Undeniably believe that which you said. Your favorite justification seemed to be on the net the simplest thing to be aware of.
I say to you, I definitely get irked while people consider worries that they plainly do not know about.
You managed to hit the nail upon the top as well as defined out the whole thing without
having side-effects , people could take a signal.
Will probably be back to get more. Thanks
Good day! Do you know if they make any plugins to safeguard against hackers?
I’m kinda paranoid about losing everything I’ve worked hard on.
Any recommendations?
After going over a few of the blog posts on your web site, I truly like your way of blogging.
I book-marked it to my bookmark website list and will
be checking back in the near future. Take a look at my website too and
tell me what you think.
Thanks for ones marvelous posting! I genuinely enjoyed reading it, you can be a great author.
I will be sure to bookmark your blog and definitely will come back in the foreseeable future.
I want to encourage you to ultimately continue your great work,
have a nice weekend!
My brother recommended I might like this blog. He was entirely right.
This post actually made my day. You can not imagine just
how much time I had spent for this information! Thanks!
Hi there to all, since I am in fact keen of reading this website’s post to be updated regularly.
It carries pleasant material.
Wow, this article is fastidious, my younger sister is analyzing such
things, therefore I am going to inform her.
Piece of writing writing is also a excitement,
if you be familiar with afterward you can write if not it is complex to write.
Piece of writing writing is also a fun, if you know afterward you can write otherwise it is complex to write.
Wow, this piece of writing is fastidious, my sister
is analyzing such things, so I am going to tell her.
At this time it looks like Expression Engine is the top blogging platform available
right now. (from what I’ve read) Is that what you are using on your blog?
I don’t know if it’s just me or if perhaps everybody else encountering
problems with your site. It looks like some
of the text on your content are running off the screen. Can somebody
else please comment and let me know if this is happening to them too?
This may be a problem with my web browser because I’ve had this happen before.
Many thanks
Please let me know if you’re looking for a
article writer for your site. You have some really great posts and I think I
would be a good asset. If you ever want to take some of the load
off, I’d love to write some articles for your
blog in exchange for a link back to mine.
Please send me an e-mail if interested. Kudos!
I just like the helpful information you supply on your articles.
I will bookmark your weblog and check again here
frequently. I’m somewhat sure I will learn plenty of new stuff proper here!
Best of luck for the next!
Unquestionably imagine that which you said. Your favourite justification appeared to be on the
internet the easiest thing to take into account of. I say to you,
I definitely get annoyed even as people think about issues that they plainly do not realize about.
You managed to hit the nail upon the highest and also defined out the entire thing with no need side
effect , people could take a signal. Will probably be again to get more.
Thanks
There’s definately a great deal to know about this topic.
I really like all the points you made.
Hello just wanted to give you a brief heads up and let you
know a few of the pictures aren’t loading correctly. I’m not sure why but I think its a linking issue.
I’ve tried it in two different browsers and both show the same outcome.
I’d like to find out more? I’d want to find out some additional information.
Thanks , I’ve just been searching for information approximately this topic for ages and yours is the best I have
came upon till now. However, what in regards to the conclusion? Are you positive concerning the supply?
great put up, very informative. I wonder why the opposite experts of this sector don’t notice this.
You must continue your writing. I am confident, you’ve a great readers’
base already!
hey there and thank you for your information – I have certainly picked up
anything new from right here. I did however expertise some technical issues using this website, as
I experienced to reload the site a lot of times previous to I could get it to load correctly.
I had been wondering if your hosting is OK? Not that I’m complaining, but sluggish loading instances times will often affect your
placement in google and can damage your high-quality score if ads and marketing with Adwords.
Anyway I’m adding this RSS to my e-mail and can look out for
a lot more of your respective interesting content. Ensure that you update this again very
soon.
Spot on with this write-up, I actually think this site
needs far more attention. I’ll probably be back
again to read more, thanks for the advice!
Wow, this piece of writing is nice, my younger sister is analyzing
these kinds of things, thus I am going to tell her.
Thank you for the auspicious writeup. It in fact was a amusement account
it. Look advanced to more added agreeable from you!
By the way, how can we communicate?
This is very interesting, You’re an overly skilled
blogger. I’ve joined your rss feed and look ahead to looking for
more of your great post. Also, I have shared your site in my social networks
It’s really a nice and useful piece of information. I am glad that you shared
this helpful information with us. Please keep us informed like this.
Thank you for sharing.
hello!,I like your writing so much! percentage we communicate extra
approximately your post on AOL? I require an expert
on this house to unravel my problem. Maybe that’s you! Having a look ahead
to peer you.
I am not sure where you’re getting your information, but great topic.
I needs to spend some time learning much more or understanding
more. Thanks for wonderful info I was looking for this information for my mission.
What’s up, I log on to your blogs on a regular basis.
Your writing style is witty, keep doing what you’re doing!
Have you ever thought about including a little bit more than just your
articles? I mean, what you say is important and all.
However think about if you added some great visuals or video clips
to give your posts more, “pop”! Your content is excellent but with pics and video clips,
this blog could certainly be one of the greatest in its niche.
Amazing blog!
First of all I want to say excellent blog! I had a quick question in which I’d like to ask if you don’t mind.
I was curious to find out how you center yourself and clear your thoughts prior to
writing. I have had trouble clearing my mind in getting my thoughts out there.
I truly do take pleasure in writing but it just seems like the first 10 to 15 minutes tend
to be lost simply just trying to figure out how to begin. Any recommendations or hints?
Thanks!
Hey are using WordPress for your blog platform? I’m new to
the blog world but I’m trying to get started and create my own. Do you require any html
coding knowledge to make your own blog? Any help would be greatly appreciated!