www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Benchmarking in D

reply Chris Mueller <ruunhb googlemail.com> writes:
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
Apr 11 2010
next sibling parent Justin Spahr-Summers <Justin.SpahrSummers gmail.com> writes:
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.
Apr 11 2010
prev sibling next sibling parent "Robert Jacques" <sandford jhu.edu> writes:
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"); }
Apr 11 2010
prev sibling next sibling parent =?ISO-8859-15?Q?=22J=E9r=F4me_M=2E_Berger=22?= <jeberger free.fr> writes:
Chris Mueller wrote:
 Hi everyone,
=20
 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.
=20
 I'm not really experienced in this field and want to ask if someone can=
 share his knowledge.
=20
 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?
=20
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 --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Apr 11 2010
prev sibling parent reply Chris Mueller <ruunhb googlemail.com> writes:
 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/
Apr 11 2010
parent reply =?ISO-8859-15?Q?=22J=E9r=F4me_M=2E_Berger=22?= <jeberger free.fr> writes:
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.
=20 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. =20
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 --=20 mailto:jeberger free.fr http://jeberger.free.fr Jabber: jeberger jabber.fr
Apr 12 2010
parent Nathan Tuggy <bugzilla nathan.tuggycomputer.com> writes:
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
Apr 13 2010