News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Profiling question

Started by Lonewolff, March 16, 2016, 02:03:32 PM

Previous topic - Next topic

Lonewolff

Hi Guys,

Is there any way to profile the output exe to show how many clock cycles were consumed?

Thanks in advance :)

jj2007

There are several well-tested ways, see The Laboratory.
If you are only interested in relative comparisons between algos, measuring milliseconds is usually precise enough. Simple example:
include \masm32\MasmBasic\MasmBasic.inc
.data
somestring db "Hello, this is a simple string intended for testing string algos. It has 100 characters without zero", 0

  Init
  NanoTimer()
  LoopCount=20000000
  mov ebx, LoopCount
  .Repeat
invoke crt_strlen, offset somestring
dec ebx
  .Until Sign?
  Print Str$("crt_strlen took %i ms\n", NanoTimer(ms))

  NanoTimer()
  mov ebx, LoopCount
  .Repeat
void len(offset somestring)
dec ebx
  .Until Sign?
  Print Str$("Masm32 len() took %i ms\n", NanoTimer(ms))

  NanoTimer()
  mov ebx, LoopCount
  .Repeat
void Len(offset somestring)
dec ebx
  .Until Sign?
  Inkey Str$("MasmBasic Len() took %i ms\n", NanoTimer(ms))

EndOfCode


Output:
crt_strlen took 715 ms
Masm32 len() took 872 ms
MasmBasic Len() took 233 ms


NanoTimer() needs the MasmBasic library, with a 100 nanosecs resolution. You can use GetTickCount instead, but note that its resolution is only around 16 ms.

Lonewolff

Nice jj2007. Thanks heaps.

It's great getting back in to MASM, really makes you think hard about every little thing you do. I have made quite a bit of progress learning (and re-learning) this today. :)