Slower than Python

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Mar 1 14:01:03 PST 2013


On 3/1/13 4:28 PM, cvk012c wrote:
> On my hardware with -inline options it now takes about 15 secs which is
> still slower than Python but with both -inline and -noboundscheck it
> takes 13 secs and finally beats Python.
> But I still kind of disappointed because I expected a much better
> performance boost and got only 7%. Counting that Python is not the
> fastest scripting language I think that similar Perl and Java scripts
> will outperform D easily.

I doubt that.

1. Microbenchmarks are a crapshoot, they exercise a tiny portion of the 
language and library.

2. With Python, after comparing 2-3 idioms - well, this is pretty much 
it. We doubled the speed in no time by just tuning options. D being a 
systems language allows you take your code to a million places if you 
want to optimize.

3. split has been discussed and improved for years in the Python 
community (just google for e.g. python split performance). Perl isn't 
all that fast actually, try this (takes 30+ seconds):

$message = "REGISTER sip:comm.example.com SIP/2.0\r
Content-Length: 0\r
Contact:
<sip:12345 at 10.1.3.114:59788;transport=tls>;expires=4294967295;events=\"message-summary\";q=0.9\r
To: <sip:12345 at comm.example.com>\r
User-Agent: (\"VENDOR=MyCompany\" \"My User Agent\")\r
Max-Forwards: 70\r
CSeq: 1 REGISTER\r
Via: SIP/2.0/TLS
10.1.3.114:59788;branch=z9hG4bK2910497772630690\r
Call-ID: 2910497622026445\r
From: <sip:12345 at comm.example.com>;tag=2910497618150713\r\n\r\n";

foreach my $i (0 .. 10000000)
{
     foreach my $notused (split(/\r\n/, $message))
     {
     }
}


Andrei


More information about the Digitalmars-d mailing list