Fragments
A Collection of Statements, kinda
Performance Monitoring

 
Post new topic   Reply to topic    Fragments Forum Index -> Site Headlines
View previous topic :: View next topic  
Author Message
martin
Site Admin


Joined: 19 Jan 2004
Posts: 455
Location: In the middle of Sweden

Reply with quote

PostPosted: Tue May 11, 2004 7:26 pm    Post subject: Performance Monitoring

Implementing performance monitors in your app is very helpful for profiling, debugging and general satisfaction of the more qualified endusers. It's also a non-trivial excercise, to put it mildly. Microsoft have done their part in making it obscure and hard to use, so naturally, we can't leave it alone, can we? This particular implementation only implements raw and delta counters, but that covers almost anything you'll ever need. The basis is there for other types of counters, though, such as instance based counters and high-precision. Both precompiled and full project source is available ... [full article]
Back to top
View user's profile Send private message Send e-mail Visit poster's website
crazylaz
Guest





Reply with quote

PostPosted: Mon Jul 25, 2005 8:33 am    Post subject:

Thank you a lot for your job.
I am really impresed about what I read. I have looked for it long time.
Now... I'm going to check it.

Regards
Back to top
mniklas



Joined: 10 Jan 2006
Posts: 3

Reply with quote

PostPosted: Wed Jan 11, 2006 10:26 am    Post subject:

Hello,

Thanks for very good article. I have added monitoring to my Delphi 4 multithread server. There were some problems: D4 is little bit old, but one thing is very strange. In PerfCounters.pas there is TPerfCounter class with abstract method:
Code:
procedure SetValue(uValue: DWORD); virtual; abstract;


This method is overriden in TRawCounter and TDeltaCounter classes, but in both cases it tries to call base class SetValue() (inherited keyword) which is abstract:
Code:

procedure TRawCounter.SetValue(uValue: DWORD);
begin
  inherited;
  fValue := uValue;
end;


D4 generates exception in such case. I have removed inherited keyword and now it works OK.

Regards,
Michal Niklas
[/code]
Back to top
View user's profile Send private message
mniklas



Joined: 10 Jan 2006
Posts: 3

Reply with quote

PostPosted: Fri Jan 13, 2006 9:55 am    Post subject:

Other problems:
1. It doesn't work on Win9x
Solution: use some {$IFDEF } or change
Code:
function LoadPerfCounterTextStrings; external 'loadperf.dll' name 'LoadPerfCounterTextStringsW';

to something like:
Code:

  if (Win32Platform = VER_PLATFORM_WIN32_NT) then begin
    dll_h := htLoadLibrary('loadperf.dll');
    f := htGetProcAddress(dll_h, 'LoadPerfCounterTextStrings');
    result := f(cmdLine, bQuietMode);
    FreeLibrary(dll_h);
  end;


2. Problem when .dll is in directory with space in name,
"c:\Program Files" is such directory. Then LoadPerfCounterTextStrings()
fails: it gets 'xxx c:\Program Files\myapp\myapp.ini' parameter and
uses 2nd parameter as file name. In this case it is 'c:\Program'.
I have changed FileNameInModPath() to use ExtractShortPathName():
Code:

function TPerfMonLib.FileNameInModPath(const sFileName: string): string;
begin
  SetLength(Result , MAX_PATH);
  SetLength(Result, GetModuleFileName(0, PChar(Result), MAX_PATH));
  Result := ExtractFileDir(Result);
  Result := IncludeTrailingPathDelimiter(Result) + sFileName;
  Result := ExtractShortPathName(Result);
end; // TPerfMonLib.FileNameInModPath
Back to top
View user's profile Send private message
martin
Site Admin


Joined: 19 Jan 2004
Posts: 455
Location: In the middle of Sweden

Reply with quote

PostPosted: Fri Jan 13, 2006 6:58 pm    Post subject:

Michal,

Thanks for sharing the fixes! I'll try to work them into the code later.

PS: If you've got more, please don't hesitate to tell us. Thanks again!
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mniklas



Joined: 10 Jan 2006
Posts: 3

Reply with quote

PostPosted: Mon Jan 23, 2006 12:16 pm    Post subject:

I have also some observation on Shared Memory.
My app is Windows Service and can by run with rights of "Local System Account" or chosen user. Performance Monitor on WinXP can see or cannot see my performance counter and it depends on user which is logged in Performance Monitor and view of PM (most common chart, counter logs, alerts). This looks different on Win2000: I cannot find user login dialog in Performance Monitor Unhappy

For my app I have added option to exchange information with Performance Monitor, but I have also added textual information that can be used by Web based monitoring tools like MRTG and Cacti.

MRTG works fine on my Windows machine, while Kylix port of my app cooperate with Cacti. They produce nice charts for last day, week, month and year. They are very useful for admins, and I think it is simplier than Windows Performance Monitor.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Fragments Forum Index -> Site Headlines All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Theme created by K.Nevelsteen