View mode: basic / threaded / horizontal-split · Log in · Help
April 11, 2010
Benchmarking in D
Hi everyone,

I would like to benchmark some of my D routines for performance testing 
 and like to compare it with some alternative implementations in e.g. 
time and memory consumption.

I'm not really experienced in this field and want to ask if someone can 
share his knowledge.

Are there some tools providing by the operating system to look at the
performance of a process? Are there any libraries in D that can help?


Chris
April 11, 2010
Re: Benchmarking in D
On Sun, 11 Apr 2010 10:27:58 +0200, Chris Mueller 
<ruunhb@googlemail.com> wrote:
> 
> Hi everyone,
> 
> I would like to benchmark some of my D routines for performance testing 
>   and like to compare it with some alternative implementations in e.g. 
> time and memory consumption.
> 
> I'm not really experienced in this field and want to ask if someone can 
> share his knowledge.
> 
> Are there some tools providing by the operating system to look at the
> performance of a process? Are there any libraries in D that can help?
> 
> 
> Chris

There's the benchmark() function in Phobos: 
http://www.digitalmars.com/d/2.0/phobos/std_date.html#benchmark

Don't know if that's what you're really looking for, though.
April 11, 2010
Re: Benchmarking in D
On Sun, 11 Apr 2010 05:27:58 -0300, Chris Mueller <ruunhb@googlemail.com>  
wrote:

> Hi everyone,
>
> I would like to benchmark some of my D routines for performance testing  
>   and like to compare it with some alternative implementations in e.g.  
> time and memory consumption.
>
> I'm not really experienced in this field and want to ask if someone can  
> share his knowledge.
>
> Are there some tools providing by the operating system to look at the
> performance of a process? Are there any libraries in D that can help?
>
>
> Chris

Here's a little benchmark routine I use:

import std.perf;
import core.thread;
import std.stdio;
import std.algorithm;

void bench(R)(string label, R delegate() dg, uint times = 1 ) {
    scope pc = new PerformanceCounter;
    real time = uint.max;
    foreach(i;0..times) {
        pc.start;
        dg();
        pc.stop;
        time = min(time,pc.microseconds/1000.0);
        Thread.yield;
    }
    writeln(label,time,"ms");
}
April 11, 2010
Re: Benchmarking in D
Chris Mueller wrote:
> Hi everyone,
> 
> I would like to benchmark some of my D routines for performance testing
>  and like to compare it with some alternative implementations in e.g.
> time and memory consumption.
> 
> I'm not really experienced in this field and want to ask if someone can
> share his knowledge.
> 
> Are there some tools providing by the operating system to look at the
> performance of a process? Are there any libraries in D that can help?
> 
	On what OS? On linux, you can do:

time foo
	to get the run time for program foo, including elapsed clock time,
time spent in the program itself and time spent in the kernel on
behalf of the program (for I/O, mallocs, etc);

cat /proc/$(pidof foo)/status
	to get memory information for a running program. I don't know any
way to get the memory information once the program exits.

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr
April 11, 2010
Re: Benchmarking in D
> There's the benchmark() function in Phobos:
> http://www.digitalmars.com/d/2.0/phobos/std_date.html#benchmark
>
> Don't know if that's what you're really looking for, though.

...

> void bench(R)(string label, R delegate() dg, uint times = 1 ) {
>     scope pc = new PerformanceCounter;
>     real time = uint.max;
>     foreach(i;0..times) {
>         pc.start;
>         dg();
>         pc.stop;
>         time = min(time,pc.microseconds/1000.0);
>         Thread.yield;
>     }
>     writeln(label,time,"ms");
> }

yep, that's what i'm missing. I give a try some of your benchmark 
suggestions for time measurements.

> On what OS? On linux, you can do:
>
> time foo
> 	to get the run time for program foo, including elapsed clock time,
> time spent in the program itself and time spent in the kernel on
> behalf of the program (for I/O, mallocs, etc);
>
> cat /proc/$(pidof foo)/status
> 	to get memory information for a running program. I don't know any
> way to get the memory information once the program exits.
>

I'm currently using XP, is there any similar way to measure memory
consumption? Otherwise i install a quick unix development environment
on a separate partition.

Thanks for your replies.

Chris


-- 
ruunhb@googlemail.com
http://ruuns.de/blog/
April 12, 2010
Re: Benchmarking in D
Chris Mueller wrote:
>> On what OS? On linux, you can do:
>>
>> time foo
>>     to get the run time for program foo, including elapsed clock time,
>> time spent in the program itself and time spent in the kernel on
>> behalf of the program (for I/O, mallocs, etc);
>>
>> cat /proc/$(pidof foo)/status
>>     to get memory information for a running program. I don't know any
>> way to get the memory information once the program exits.
>>
> 
> I'm currently using XP, is there any similar way to measure memory
> consumption? Otherwise i install a quick unix development environment
> on a separate partition.
> 
	I believe that the task manager can give that information. Hit
Ctl-Alt-Del, then click on the "Task Manager" button. One of the
tabs gives information about the running processes. You might need
to configure the displayed columns, but I don't remember how it's
done and I don't have an XP box on hand to check.

		Jerome
-- 
mailto:jeberger@free.fr
http://jeberger.free.fr
Jabber: jeberger@jabber.fr
April 13, 2010
Re: Benchmarking in D
On 2010-04-12 11:09, "Jérôme M. Berger" wrote:
> Chris Mueller wrote:
>>> On what OS? On linux, you can do:
>>>
>>> time foo
>>>      to get the run time for program foo, including elapsed clock time,
>>> time spent in the program itself and time spent in the kernel on
>>> behalf of the program (for I/O, mallocs, etc);
>>>
>>> cat /proc/$(pidof foo)/status
>>>      to get memory information for a running program. I don't know any
>>> way to get the memory information once the program exits.
>>>
>>
>> I'm currently using XP, is there any similar way to measure memory
>> consumption? Otherwise i install a quick unix development environment
>> on a separate partition.
>>
> 	I believe that the task manager can give that information. Hit
> Ctl-Alt-Del, then click on the "Task Manager" button. One of the
> tabs gives information about the running processes. You might need
> to configure the displayed columns, but I don't remember how it's
> done and I don't have an XP box on hand to check.
>
> 		Jerome

On Vista: View -> Select Columns and make sure Private Working Set is 
checked. On XP, checking Memory Usage will get you most of the way 
there, although it's not quite as good (it lumps in any working set 
shared with other processes too).
-- 
~ My software never has bugs. It just develops random features. ~ 
http://tagzilla.mozdev.org v0.066
Top | Discussion index | About this forum | D home