flat assembler
Message board for the users of flat assembler.

Index > Windows > Performance Profiling

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
keenin



Joined: 25 Aug 2003
Posts: 33
keenin 27 Oct 2003, 11:22
Hi,

I have been searching for a performance profiler that is compatible with purely in assembly written software, but I sadly found none; each one needs debug information, symbol tables, and so on.

Performance profilers are relatively easy: They should profile the function times, do a line by line analysis, and output its results as disassembled code. I'd even glad if there was a performance profiler that only profiles the functions.

Is there a performance profiler that is compatible with code that has no such debug information? Or is it maybe possible to hand-code them with FASM?

keenin.
Post 27 Oct 2003, 11:22
View user's profile Send private message Reply with quote
scientica
Retired moderator


Joined: 16 Jun 2003
Posts: 689
Location: Linköping, Sweden
scientica 27 Oct 2003, 11:49
Are you looking for some program that basically easures the Ticks (or milli secs) it takes to execute an procedure?

Then the explanation is quite simple why you need to give symbolic and/or debug info to the profiler, since it's just pice of dumb software, it can't guess where the funcitons begin, and when guessiung there is a risc of guessing wrong (look at your app while using ollydebug, not always does she see that there is a function under you nose). I don't know how these debug and symbolic info files/sections are contsructed (haven't found any docs on them, if you know any please post a link), maybe it can be done relativley simple to make them by hand/macros.

_________________
... a professor saying: "use this proprietary software to learn computer science" is the same as English professor handing you a copy of Shakespeare and saying: "use this book to learn Shakespeare without opening the book itself.
- Bradley Kuhn
Post 27 Oct 2003, 11:49
View user's profile Send private message Visit poster's website Reply with quote
keenin



Joined: 25 Aug 2003
Posts: 33
keenin 27 Oct 2003, 17:02
Yes, basically, it should measure the complete execution time of each procedure; so the most time consuming procedure can be spotted and, thus, be optimized.

Yes, there are awfully few informations about debugging data like symbol tables available. The most common ones under Windows are CodeView (a little bit older) and PDB (in seperate file).
Generally, STABS is also widely used (but not understood by OllyDbg:).

I only found out that the PDB format is described in the book 'Undocumented Windows 2000 Secrets: A Programmer's Cookbook' - maybe anyone ownes that?

If unlikely allowed in the license (I don't know it), the file DBGHELP.DLL from Windows (also included in OllyDbg) can be analyzed as it handles that part for a lot of debuggers, but that may be too much work.

Hopefully, you know other resources or applicable techniques or both.

keenin.
Post 27 Oct 2003, 17:02
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 27 Oct 2003, 20:07
You should try Maverick's profiler, I'm attaching it here, but can also get it from the original thread on Win32ASM message board: http://board.win32asmcommunity.net/showthread.php?s=&threadid=7510
(read provided documentation carefully).


Description: Maverick's PROFILE v2.0
Download
Filename: profile.zip
Filesize: 5.47 KB
Downloaded: 702 Time(s)

Post 27 Oct 2003, 20:07
View user's profile Send private message Visit poster's website Reply with quote
keenin



Joined: 25 Aug 2003
Posts: 33
keenin 27 Oct 2003, 23:24
Thanks for the suggestion, I did not know Maverick's Profiler; it is really good for optimizing code. I tried it out and think that it is best used with different version of one procedure to determine which one is faster. I have searched exactly that kind of line-by-line profiler!

Yet, I am searching a function profiler to spot the functions that have to be optimized - with help of Maverick's Profiler:).

keenin.
Post 27 Oct 2003, 23:24
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 27 Oct 2003, 23:49
BTW, I've made a nice small skeleton interface for it, for anyone wanting to quickly profile some code. Just put your code after the "function" label in the source below and compile it with the profile.bin in the same directory:
Code:
include '%include%\win32ax.inc'

entry start

section '.func' code readable executable

  ; function to be profiled

  function:



        ret

section '.prof' code readable writeable executable

  profiler file 'profile.bin'
           rb (profiler+2000h)-$

  label init at profiler+559
  label profile at profiler+1
  label cycles qword at profiler+1000h
  label cycles_low dword at cycles
  label cycles_high dword at cycles+4

section '.bss' readable writeable

  strbuffer rb 100h

section '.text' code readable executable

  start:

        call    init
        stdcall profile,function

        cinvoke wsprintf,strbuffer,'Function is taking %d cycles.',[cycles_low]
        invoke  MessageBox,0,strbuffer,'Profiler',MB_OK

        invoke  ExitProcess,0

section '.idata' import data readable writeable

  library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'

  import kernel,\
         ExitProcess,'ExitProcess'

  import user,\
         wsprintf,'wsprintfA',\
         MessageBox,'MessageBoxA'
    
Post 27 Oct 2003, 23:49
View user's profile Send private message Visit poster's website Reply with quote
GuyonAsm



Joined: 27 Sep 2003
Posts: 45
GuyonAsm 28 Oct 2003, 00:27
yay thanks, i can use this for one of my science projects for school to test how fast an algo is(is this tool efficient enough?).

_________________
I shall not evade what is predestined
because every battle, is another lesson
- GuyonAsm.

A Believer of The System.
Post 28 Oct 2003, 00:27
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 28 Oct 2003, 08:58
Didn't maverick said something about loading profiler.bin into memory returned by VirtualAlloc to make it 64k aligned or something like that?
Post 28 Oct 2003, 08:58
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
keenin



Joined: 25 Aug 2003
Posts: 33
keenin 28 Oct 2003, 11:56
Maverick said that it should be 4k aligned. As each section is that, Privalov defines a new section for PROFILE.BIN and for the function.

I did it a little bit different, though; I would add the function anywhere else to profile more than one function and copy that function to the aligned space.

Code:

function_aligned:
...

function_1:
    ...
    ret
function_1_size = $-function_1

function_n:
    ...
    ret
function_n_size = $-function_n

...

call init

mov ecx,function_1_size
mov esi,function_1
mov edi,function_aligned
rep movsb
pushd function_aligned
call profile

...

    
Post 28 Oct 2003, 11:56
View user's profile Send private message Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 28 Oct 2003, 13:09
My mistake then.

I just find my results weird. 8 nops in 1 cycle, while 9 nops in 0 cycle.
Post 28 Oct 2003, 13:09
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
keenin



Joined: 25 Aug 2003
Posts: 33
keenin 28 Oct 2003, 14:50
Two NOP should be 1 cycle.

You could try using

align(1024*4)
profiler rb 1024*8
function_aligned rb 1024*8

and copying PROFILE.BIN to profiler

or (is larger)

align(1024*4)
profiler file 'profile.bin'
rb 1024*8-$+profiler
function_aligned rb 1024*8

Maybe that works for you.

keenin.
Post 28 Oct 2003, 14:50
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8351
Location: Kraków, Poland
Tomasz Grysztar 28 Oct 2003, 15:17
roticv wrote:
I just find my results weird.

Yes, it still seems to a bit unrealiable in some case - we should talk to Maverick, but unfortunatly he's not with us right now.
Post 28 Oct 2003, 15:17
View user's profile Send private message Visit poster's website Reply with quote
GuyonAsm



Joined: 27 Sep 2003
Posts: 45
GuyonAsm 28 Oct 2003, 17:14
are you trying to say that he is deceased? i hope not Sad

_________________
I shall not evade what is predestined
because every battle, is another lesson
- GuyonAsm.

A Believer of The System.
Post 28 Oct 2003, 17:14
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
comrade 26 Jun 2004, 16:42
he stopped asm, at least win32asmboard after some scuffle on it

http://board.win32asmcommunity.net/showthread.php?s=&postid=110517#post110517

Quote:
Maverick wrote:
Thank you all for the happy birthday wishes.. it was a happy birthday actually.

The things that were written here in this thread are correct: I didn't appreciate the lack of position/action of the administrators/moderators of the board regarding those silly and extreme insults that a member did.
Not that I was really angry or anything about it, but it sincerely made me lose interest to spend my time on a board that allows this - it was a matter of principle, you know - although I'm still fond of many of you, mods included (because, apart from that episode that disappointed me, I still see many of them as friends I've a direct relationship with, with whom I swapped emails, had a good time, etc..).

Currently I'm developing some utilities, for selling them as shareware (I need to make a living too, you know). I think I'll be back on the board actively, but I still need a period of pause to get motivated to contribute significatively (something I've never done so far, unfortunately).

Anyway, take care and thank you very much for all the personal messages, and for this thread. It was very much appreciated.

See you some day!

Greets,
FabI/O

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 26 Jun 2004, 16:42
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Jun 2004, 09:59
i once wrote my own profiler, which overloaded "ENTER" and "RETURN" macros, with code that saved profiling info, and it worked nice.
Post 27 Jun 2004, 09:59
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 27 Jun 2004, 12:09
can you post it?
Post 27 Jun 2004, 12:09
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 27 Jun 2004, 14:39
I used my own "proc" macro, so it won't be vary useful. But anyway, here it is. I also used few more own macros there, but i think you can figure out idea from it.

btw, this way isn't good for serious profiling, because it misses multitasking aspect, and sometimes it even displays negative values (?bug), but it gave me idea which procedure wastes most time.

I think it would be possible to write something such for FASM's standard procedure macro.


Description:
Download
Filename: Profiler.zip
Filesize: 2.12 KB
Downloaded: 606 Time(s)

Post 27 Jun 2004, 14:39
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
decard



Joined: 11 Sep 2003
Posts: 1092
Location: Poland
decard 27 Jun 2004, 15:16
I have similar problem with Maverick's profiler. For example when my proc is just "xor eax,eax", than it shows "-2" cycles... Confused
Post 27 Jun 2004, 15:16
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 29 Jun 2004, 15:29
i quess it's something with multitasking, but dont know...
Post 29 Jun 2004, 15:29
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
roticv



Joined: 19 Jun 2003
Posts: 374
Location: Singapore
roticv 29 Jun 2004, 16:15
Maybe it is pairing of instructions.
Post 29 Jun 2004, 16:15
View user's profile Send private message Visit poster's website MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
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
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.