D compiler benchmarks

Robert Clipsham robert at octarineparrot.com
Sat Mar 7 16:43:14 PST 2009


Daniel Keep wrote:
> 
> Robert Clipsham wrote:
>> ...
>>
>> (if anyone knows an easy way to get the memory usage of a
>> process in D, let me know :D).
> 
> There's a way to do it in Phobos;
> 
>> import gc=std.gc;
>> import gcstats;
>>
>> void main()
>> {
>>     GCStats gcst;
>>     gc.getStats(gcst);
>> }
> 
> 
> I went hunting through Tango, and it looks like it has the same method;
> it just isn't exposed.  Probably because of this comment:
> 
> // NOTE: This routine is experimental.  The stats or function name may
> //       change before it is made officially available.
> 
> None the less, if you want it now, you could try adding this to your
> code somewhere:
> 
>> struct GCStats
>> {
>>     size_t poolsize;        // total size of pool
>>     size_t usedsize;        // bytes allocated
>>     size_t freeblocks;      // number of blocks marked FREE
>>     size_t freelistsize;    // total of memory on free lists
>>     size_t pageblocks;      // number of blocks marked PAGE
>> }
>>
>> extern(C) GCStats gc_stats();
> 
> You should probably whack this in a module so you can replace it easily
> if and when it changes.
> 
> 
>   -- Daniel
I was thinking more a way of getting the memory usage using run.d (the 
app I'm using for benchmarking, it's in the repository if you're 
interested). It's rather difficult to get the memory usage in run.d so I 
can put it straight into the stats page if it's being got from within 
benchmark, and doing this would probably affect the benchmark some 
amount which I would ideally like to avoid.



More information about the Digitalmars-d mailing list