comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Benchmark Ada, please
Date: Sat, 05 Jul 2014 21:29:20 +0300
Date: 2014-07-05T21:29:20+03:00	[thread overview]
Message-ID: <c1qug1FcogaU1@mid.individual.net> (raw)
In-Reply-To: <lp9b07$oph$1@speranza.aioe.org>

On 14-07-05 20:00 , Guillaume Foliard wrote:
> Hello,
> 
> Niklas Holsti wrote:
>> On 14-07-05 14:34 , Guillaume Foliard wrote:
>>> Here are the numbers with GNAT GPL 2014 on a Core2 Q9650 @ 3.00GHz:
>>>
>>> $ gnatmake -O3 rbc_ada.adb
>>> $ time ./rbc_ada
>>> ...
>>> Elapsed time is = 1.966112682
>>>
>>>
>>> As for the C++ version:
>>>
>>> $ g++ -o testc -O3 RBC_CPP.cpp
>>> $ time ./testc
>>> ...
>>> Elapsed time is   = 3.12033
>>
>> Are you sure that Ada.Execution_Time.Clock gives numbers that can be
>> compared with the get_cpu_time() function in the C++ version? For a
>> program running under an OS, it is not evident what should be included
>> in the "processor time" for a program (program loading, process
>> creation, interrupts, I/O, page faults, ...).
> 
> I did these tests on Linux. On that platform, Ada.Execution_Time.Clock is 
> merely a call to the POSIX call clock_gettime() (itself a system call under 
> the hood), with CLOCK_THREAD_CPUTIME_ID as the clock_id parameter.

So at least they use the same POSIX library function, good.

> In the 
> GNAT GPL 2014 environment have a look at lib/gcc/x86_64-pc-linux-
> gnu/4.7.4/adainclude/a-exetim.adb to notice that yourself.

I believe you. I was asking if you had checked that the two clock
functions are equivalent. I did not mean to criticize.

> Let's now check the differences between clock() and clock_gettime(). 
> ...
> clock_gettime(CLOCK_THREAD_CPUTIME_ID, {0, 760910}) = 0
> clock_gettime(CLOCK_PROCESS_CPUTIME_ID, {0, 778713}) = 0
> ...
> 
> We can notice that under Linux clock() is in fact a wrapper above 
> clock_gettime(). So the only difference between Ada.Execution_Time.Clock and 
> clock() is the clock ID given to clock_gettime().

So they are not exactly the same.

> Moreover in RBC_CPP.cpp, if you rewrite the get_cpu_time() function as 
> follows:

  [using CLOCK_THREAD_CPUTIME_ID]

> and run the test again, you will find a value similar to the previous one.

Good. (But I'm not at all sure that I would find similar values on my
host system and my compilers, as demonstrated by other posts in this
thread.)

> 
>> What did the "time" command output in your tests?
> 
> For the command it is given as argument, "time" reports the elapsed time 
> ("real time"), the CPU time spent in user mode ("user time") and the CPU 
> time spent in system mode ("sys time"). I just used it to double check the 
> CPU time values.

I know well what "time" does; I asked you to show the values it produced
so that we could see that they, too, show Ada to be faster. If you don't
want to do that, that is your right, of course.

>> Just to be sure that the claim "Ada is faster" is really motivated.
>> Which would be very nice.
> 
> I suppose we are now surer than ever.

I was not at all sure, for the reasons I gave. I am surer now, thank you.

From other posts it seems that the relative speeds of C++ and Ada for
this benchmark depend on the platform and compiler, which is not very
surprising.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
      .      @       .

  reply	other threads:[~2014-07-05 18:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-04 17:23 Benchmark Ada, please Victor Porton
2014-07-05 12:34 ` Guillaume Foliard
2014-07-05 13:00   ` Niklas Holsti
2014-07-05 17:00     ` Guillaume Foliard
2014-07-05 18:29       ` Niklas Holsti [this message]
2014-07-05 18:44         ` Niklas Holsti
2014-07-05 18:50         ` Guillaume Foliard
2014-07-05 19:09           ` Niklas Holsti
2014-07-05 16:33   ` Simon Wright
2014-07-05 18:25     ` Guillaume Foliard
2014-07-06 17:24   ` Dirk Heinrichs
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox