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.
Why viewers still make use of to read news papers when in this technological globe the whole thing
is available on net?
There’s certainly a lot to learn about this issue.
I love all of the points you made.
Quality posts is the main to interest the people to pay a visit the website, that’s what this web site is providing.
Remarkable! Its in fact amazing article, I have got much clear idea concerning from this post.
What a material of un-ambiguity and preserveness of precious familiarity regarding unexpected emotions.
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored subject matter stylish.
nonetheless, you command get bought an nervousness over that you wish
be delivering the following. unwell unquestionably come more formerly
again as exactly the same nearly a lot often inside case you shield this hike.
Your style is unique in comparison to other folks I have read stuff from.
Thank you for posting when you have the opportunity, Guess I’ll just book mark this web
site.
I am in fact pleased to read this webpage posts which
contains plenty of useful facts, thanks for providing these data.
Hey there, I think your website might be having
browser compatibility issues. When I look at your blog site in Chrome, it looks fine but when opening in Internet
Explorer, it has some overlapping. I just wanted to give you a quick heads
up! Other then that, excellent blog!
Undeniably believe that which you said. Your favorite reason appeared to be at the net the easiest thing
to take into account of. I say to you, I definitely get annoyed
whilst other folks consider concerns that they plainly do not know about.
You controlled to hit the nail upon the top and outlined out the entire thing without
having side-effects , other folks can take a signal.
Will probably be again to get more. Thanks
My brother suggested I may like this blog. He was once entirely right.
This put up truly made my day. You cann’t believe simply how a lot time I had spent for
this information! Thanks!
Good day! I could have sworn I’ve visited this website before but after browsing through some of the
posts I realized it’s new to me. Regardless, I’m certainly pleased I
found it and I’ll be bookmarking it and checking back frequently!
Normally I don’t learn post on blogs, but I wish to say that this write-up very compelled me to
try and do it! Your writing style has been amazed me. Thank you,
very nice article.
Greate pieces. Keep writing such kind of info on your blog.
Im really impressed by your site.
Hey there, You’ve done an excellent job. I will certainly digg it and in my opinion recommend
to my friends. I’m confident they’ll be benefited from this site.
Today, I went to the beach with my children. I found a sea shell and gave it
to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She placed the shell to her ear and screamed.
There was a hermit crab inside and it pinched her
ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!
Greetings! Very helpful advice within this article!
It is the little changes that will make the greatest changes.
Many thanks for sharing!
My developer is trying to convince me to move to .net from PHP.
I have always disliked the idea because of the costs.
But he’s tryiong none the less. I’ve been using Movable-type on several websites for about a year and am concerned about switching to
another platform. I have heard great things about blogengine.net.
Is there a way I can transfer all my wordpress content into it?
Any kind of help would be greatly appreciated!
Appreciate the recommendation. Will try it out.
Wow, superb weblog layout! How long have you been blogging for?
you made blogging look easy. The whole glance of your site is magnificent,
as smartly as the content material!
Appreciating the commitment you put into your site and in depth information you provide.
It’s awesome to come across a blog every once in a while that isn’t the same old
rehashed material. Wonderful read! I’ve bookmarked your site and I’m including your RSS feeds to my Google account.
Everything is very open with a really clear clarification of the challenges.
It was truly informative. Your website is very useful.
Many thanks for sharing!
Appreciate the recommendation. Let me try it out.
Hello to every body, it’s my first visit of this web site;
this webpage includes remarkable and actually good data designed for readers.
It’s awesome in support of me to have a web site, which is valuable for my know-how.
thanks admin
Hello to every single one, it’s really a good for me to pay a quick visit this site,
it consists of helpful Information.
Hello my family member! I want to say that this article is awesome,
great written and come with approximately all significant infos.
I’d like to look extra posts like this .
fantastic publish, very informative. I’m wondering why the other specialists of this sector don’t understand this.
You must continue your writing. I’m sure, you’ve a great readers’ base already!
I’m not that much of a online reader to be honest but your sites really nice, keep it up!
I’ll go ahead and bookmark your site to come back later.
Cheers
Admiring the hard work you put into your blog and detailed information you provide.
It’s good to come across a blog every once in a
while that isn’t the same out of date rehashed information. Great read!
I’ve saved your site and I’m including your RSS feeds
to my Google account.
I am really pleased to read this website posts which includes lots of helpful information, thanks for providing these kinds of statistics.
I am sure this paragraph has touched all the internet people, its really really good piece of
writing on building up new web site.
I am sure this post has touched all the internet users, its really really good piece of writing on building up new weblog.
Thanks for another excellent article. The place
else may just anybody get that kind of information in such a perfect approach
of writing? I have a presentation next week, and I am at the search for such info.
I visit each day some websites and websites to read posts, except this blog gives
feature based writing.
I loved as much as you will receive carried out right here.
The sketch is attractive, your authored material stylish.
nonetheless, you command get got an shakiness over that you wish be delivering the following.
unwell unquestionably come further formerly again since exactly the
same nearly a lot often inside case you shield this hike.
I was recommended this web site by my cousin. I’m not
sure whether this post is written by him as nobody else
know such detailed about my problem. You’re incredible!
Thanks!
I’m extremely pleased to find this web site. I want to to thank you for ones
time for this wonderful read!! I definitely savored every little bit of it and i also have you
book-marked to see new information in your website.
Aw, this was a really nice post. Taking a few minutes and actual effort to
generate a really good article… but what can I say…
I hesitate a whole lot and don’t manage to get anything done.
Have you ever thought about publishing an e-book or guest authoring on other
websites? I have a blog based on the same information you discuss and
would love to have you share some stories/information. I know my readers would value
your work. If you’re even remotely interested, feel free to send me an e-mail.
After I initially commented I appear to have clicked the
-Notify me when new comments are added- checkbox and from now on whenever a comment is added I receive 4 emails with the exact same comment.
Perhaps there is an easy method you are able to remove me from that service?
Thank you!
Hello there! Do you know if they make any plugins to help
with SEO? I’m trying to get my blog to rank for some targeted keywords but I’m not seeing very good results.
If you know of any please share. Appreciate it!
It’s nearly impossible to find experienced people for this topic,
however, you seem like you know what you’re talking about!
Thanks
Have you ever thought about creating an e-book or guest authoring on other sites?
I have a blog based on the same topics you discuss and would love to have you share some stories/information. I
know my audience would value your work. If you are
even remotely interested, feel free to send me an e-mail.
Have you ever thought about including a little bit more
than just your articles? I mean, what you say is important and everything.
But think about if you added some great images or videos to give your
posts more, “pop”! Your content is excellent but with pics and clips, this blog could undeniably be one of the best
in its field. Terrific blog!
Hello just wanted to give you a quick 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 internet browsers and both show the same outcome.
Does your blog have a contact page? I’m having problems locating it but, I’d like
to shoot you an e-mail. I’ve got some suggestions for your blog
you might be interested in hearing. Either way, great website and I look forward to seeing it improve over time.
Hi there! I know this is somewhat 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 alternatives for another platform. I would be awesome if you could
point me in the direction of a good platform.
Pretty! This has been an extremely wonderful post.
Thank you for providing this information.
It’s going to be finish of mine day, however before ending I am reading this
enormous article to improve my know-how.
Magnificent beat ! I wish to apprentice even as you amend your web
site, how can i subscribe for a weblog web site?
The account helped me a acceptable deal. I were a little bit acquainted of this your
broadcast provided bright transparent concept