Michells Mesterværk

For Loop performance i ASP, PHP og ASP.NET

by Administrator 15. September 2009 14:53

opdatering

Dette er blot et forsøg på at lave en benchmark i forskellige sprog/frameworks. Du skal ikke tage disse eksempler for gode benchmarks.

Jeg har længe gerne villet undersøge hvilket sprog/framework der reelt set er hurtigst. Hurtigst i den forstand, at måle tid på visse funktionskald, såsom et for loop eller en henting af data fra en database.

Idag har jeg forsøgt at lave noget performance på et meget basalt loop.

PHP (Tid: 0.785732)

<?php
$time_start = microtime(true);

for($number = 0; $number < 10000000; $number++){
    
}

$time_end = microtime(true);
$totaltime = number_format(($time_end - $time_start), 10);

echo $totaltime;
?> 

ASP (Tid: 1.511719)

<%

StartTime = Timer

For intCounter = 0 to 10000000
    
Next

EndTime = Timer
TimeIt = EndTime - StartTime

Response.Write TimeIt

%>

ASP.NET med C# (Tid: 0.043093)

using System;
using System.Diagnostics;

namespace ForLoopPerf {
    public partial class _Default : System.Web.UI.Page {
        protected void Page_Load( object sender, EventArgs e ) {
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();

            for ( int i = 0; i < 10000000; i++ ) {
                
            }

            stopwatch.Stop();
            Response.Write( "Time elapsed:<br>" +
                stopwatch.Elapsed );
        }
    }
}

PHP var eksekveret under både Apache (WAMP) og IIS7 (FastCGI) og der var ikke mærkbar forskel.

ASP.NET eksekveret under debug mode under Casini.

ASP eksekveret under IIS7.

Tid anført i sekunder

Tags:

Comments

9/15/2009 3:55:24 PM #

Brian

Hvis du gerne vil vide, hvilke sprog der generelt set er hurtigst til en given opgave, synes jeg, du bør finde nogle reelle opgaver at sammenligne. Det er ikke ret interessant hvilket sprog, der kan afvikle en tom løkke hurtigst.

Det kan tilmed være at compileren/JIT-compileren er smart nok til at gennemskue, at du ikke laver noget i løkken og derfor helt lader være at generere kode for den del. I så fald kommer du til den såre indlysende konklusion, at noget er langsommere end intet. Well, fair enough, men ikke enormt relevant.

Under alle omstændigheder er det langt mere interessant, hvilket sprog/platform der er hurtigst til reelle opgaver. Ville du vælge platform baseret på hvilken af de mulige, der kører tomme løkker hurtigst?

Brian Denmark

9/16/2009 12:22:21 AM #

Jakob Andersen

Jeg hørte for nylig en udtale "Benchmarks don't lie, people that do benchmarks does" Smile

Kan kun tilslutte mig Brians kommentarer, det er en dybt subjektiv test du har foretaget, desuden er der mange ting der kan stilles spørgsmålstegn ved f.eks. overhead i forbindelse med parsing/JIT'ing af kode som også har en stor del at betyde i real life scenarier.

Jakob Andersen Denmark

9/16/2009 9:15:38 AM #

Emil Refn

Hvordan er testen i det hele taget udført? har du kørt testen en gang eller flere gange og taget gennemsnittet?

Emil Refn Denmark

9/16/2009 9:16:43 AM #

Emil Refn

Glemte at sige at idéen med at benchmarke forskellige sprog er god nok, det skal bare gøres på en ordentlig måde Smile

Emil Refn Denmark

10/22/2009 7:03:01 AM #

faxless payday loans

The inimitability of your blog is leading from the front in the arena of blog! Thanks --------------------

faxless payday loans United Kingdom

10/28/2009 6:06:22 AM #

Payday Loans No Teletrack

The exclusivity of your info is very nice. We all wait for such nice post………………… Thanks for the post.

Payday Loans No Teletrack United States

10/29/2009 7:01:45 AM #

Sameday Payday Loans

I have achieved my target by your help.

Sameday Payday Loans United States

11/6/2009 9:11:25 AM #

Cheap Payday Loans

I liked it please keep writing……

Cheap Payday Loans United Kingdom

11/9/2009 9:05:00 AM #

Contract Mobile Phones deals

Nice site and useful information…………

Contract Mobile Phones deals United Kingdom

11/10/2009 9:52:22 AM #

taj mahal tours india

I like to read blog in coding forms. Keep it up and thanks a lot for making this nice post.........

taj mahal tours india

11/13/2009 7:20:03 AM #

faxless payday loans

Just wanted to say thanks for this.

faxless payday loans United States

11/13/2009 10:09:56 PM #

payday loans

Do you make money out of this blog? just curious

payday loans United States

11/18/2009 10:29:15 AM #

payday loans

I like what I see. keep it going

payday loans United States

11/18/2009 10:17:21 PM #

payday loans

I like what I see. keep it going

payday loans United States

12/29/2009 2:33:09 PM #

MA Payday Loans

Thank you for your help!

MA Payday Loans United States

1/26/2010 11:03:48 AM #

same day loans

Every action of our lives touches on some chord that will vibrate in eternity.

same day loans United States

2/14/2010 1:35:37 PM #

اخبار

Thank you very much for the possibility to have a look into the office. Nice boy, he has got the talent to explain.

اخبار Egypt

2/23/2010 4:02:56 PM #

teeth white

Every time you smile at someone, it is an action of love, a gift to that person, a beautiful thing.

teeth white United States

2/28/2010 11:29:20 AM #

stocks

Most of the time I don’t make comments on blogs, but I'd like to say that this article really made me to do so. Thanks!

stocks United States

3/14/2010 11:19:19 PM #

ssk sorgulama

This is a really good read for me, Must admit that you are one of the best bloggers I ever saw.Thanks for posting this informative article.

ssk sorgulama United States

3/17/2010 11:25:52 AM #

arac sorgulama

I admire the valuable information you offer in your articles. I will bookmark your blog and have my children check up here often. I am quite sure they will learn lots of new stuff here than anybody else!

arac sorgulama United States

3/20/2010 3:18:44 PM #

ehliyet

Excellent post.I want to thank you for this informative read, I really appreciate sharing this great post. Keep up your work.

ehliyet Denmark

3/25/2010 5:00:54 AM #

quick cash loan

my God, i thought you were going to chip in with some decisive insght at the end there, not leave it with ‘we leave it to you to decide’.

quick cash loan United States

3/26/2010 2:41:48 PM #

fast payday cash advance

There are certainly a lot of details like that to take into consideration.

fast payday cash advance United States

3/29/2010 2:09:33 PM #

quick payday loans

I would like to thank you for the efforts you have made in writing this article. I am hoping the same best work from you in the future as well.

quick payday loans United States

3/30/2010 2:37:41 AM #

personal bad credit loan

Very interesting post - Might be old news, but it was news to me.

personal bad credit loan United States

3/31/2010 6:11:44 PM #

strech marks treatment

Hey, i've been reading this blog for a while and have a question, maybe you can help... it's how do i add your feed to my rss reader as i want to follow you. Thanks.

strech marks treatment United States

4/5/2010 6:04:36 AM #

love calculator

Hi, I was looking on the net  and I discovered your website. Keep up the good work.

love calculator United States

4/7/2010 4:01:48 AM #

Clemmie Carbal

Hello - I must say, I’m impressed with your site. I had no trouble navigating through all the tabs and information was very easy to access. I found what I wanted in no time at all. Pretty awesome. Would appreciate it if you add forums or something, it would be a perfect way for your clients to interact. Great job

Clemmie Carbal United States

4/7/2010 9:23:42 PM #

Alabama Payday Loans

A man is a success if he gets up in the morning and gets to bed at night, and in between he does what he wants to do.

Alabama Payday Loans United States

Add comment


(Will show your Gravatar icon)

(De 3 specielle karaktere i det danske alfabet?)
  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.6.0.0
Theme by Mads Kristensen