Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Memory Information That no ones got any infomation about. 1

Status
Not open for further replies.

RossMcIvor

Programmer
Jan 24, 2007
9
GB
hi eveyone,

First for the blog out there that reads FreePhy FreePageFile and stuff, This aint about that :)

I want to make a little program in delphi (v 2005) that will read that memory speed, explained the speed that data is writen to memory eg DDR400, doing 400MHz, I dont know the speed it writes, or reads but 400,000,000 bits per second is a rough guess (but I'm sure that the double rate means that I'm more than likly wrong :)),

I've looked around for some code, in delphi, and even some pains taking time looking at Assembly to do it for me.. seems like I'm stuck, the only thing that I can gather to a point is sizes and chunks that allocate and then fill, giving me some exreamly large numbers).

Could anyone help or face me in the light of truth that maybe it cant be done unless its machine code :)

Ross...

 
You mean a memory speed benchmark?

I'm not sure it'd be wholly accurate, but what I'd do to attempt such a thing is this:

1) allocate a large block of memory, but make sure you don't hit the page file with it.
2) Then write/read a sufficiently large amount of times to that memory space, keeping track of how many times.
3) then do the math to determine your speed.

Of course, lowering the amount of program overhead in the benchmark loop would be a priority.
 
It probobly is possible to read the memory chip device information, programs like SiSoft Sandra do this.
Don't know if it can be done with Delphi.


Steve [The sane]: Delphi a feersum engin indeed.
 
Thanks,

Would anyone know how I could do this, I think I have to work with a TmemoryStream, but its getting enuf data to put into it, and where from, could it be just text, or does it have to be biniary for a better result.. if so ... I dont know where to start I've had no dealing with binary apart from true and false..

Thanks again for the suggestion.. and I really think to this is the way to go.
 
I just decided to try to write a memory benchmark myself just to see what it would look like, and it ended up being a pretty short affair. I don't know if I have any particular bugs or anything in the code, or if my methodology is incorrect (I'm sure that's another interesting debate), but what I ended up doing was this:

1) Allocate 70% of the available physical memory, then adjust to the nearest megabyte (for easier calculations later).
2) Then start a TTimer control for a 15 second duration.
3) Then I have a loop which has the FillChar function, an increment of a counter to track the number of times the loop runs, and Application.ProcessMessages. Loop ends when the TTimer control event kicks in and disables itself.
4) Then take the MB * the counter and divide it by 15 to produce a megabytes per second number.

In truth, the megabytes per second is much higher than you think. ;)

And like I say too, there's probably lots of ways to knock out code time in that loop and ultimately push that number higher (Fastcode, alternative to TTimer?).
 
don't rely on TTimer when trying to benchmark.

reason for this is that TTimer uses WM_TIMER messages that are sent to it's window, problem is that those messages can be delayed (they follow your main app's message pump) due to the high cpu load of your benchmark.

to measure time, use QueryPerformanceCounter instead:

Code:
function WinTimeGetTime : DWord;

var Count : TLargeInteger;
    HighPart : DWORD;
    LowPart : DWORD;

begin
{ Centralized timer method -- will use QueryPerformaceCounter }
{ if avail, return is the number of ms since the system started }
 if QPFreq <> 0 then
  begin
   QueryPerformanceCounter(Count);
   HighPart := QPCCast(Count).HighPart;
   LowPart := QPCCast(Count).LowPart;
   asm
    xor edx, edx
    mov eax, HighPart
    div QPFreq
    mov eax, LowPart
    div QPFreq
    mov Result, eax
   end;
  end
 else Result := timeGetTime;
end;

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
oops, forgot some parts:

unit initialization
Code:
var Freq : TLargeInteger;

initialization
 QueryPerformanceFrequency(Freq);
  { Our assumption that HighPart is zero should be good for }
  { a long time but we'll do this safety check just in case }
 if (QPCCast(Freq).HighPart <> 0) or (QPCCast(Freq).LowPart = 0) then Exit;
 QPFreq:=QPCCast(Freq).LowPart div 1000;
 if (QPCCast(Freq).LowPart mod 1000) > 500 then Inc(QPFreq);
end.


QPCcast definition:

Code:
type  QPCCast = record
       LowPart: DWORD;
       HighPart: DWORD;
      end;

code is made by the terrific guys of Turbopower... (look in oomisc unit of APRO package)

//Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Thats really good.. I knew that asm bypassed windows opreations for nealy everything just wondering what I would do about implemting it around TMemoryStream, and do you think that it also would have to be writen in asm., too again, bypass the windows memory managment and hopfuly get a nice hardware benchmark rather than with messages, maybe I'm wrong, maybe Tmemorystream is fast enuf and there is no need for any asm code in that direction :)

thanks alot, I was also looking for the same kind of Timer code for the rest of the parts I got.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top