News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Open, Read, Close: Distribution of the duration

Started by jj2007, November 28, 2017, 10:37:25 PM

Previous topic - Next topic

jj2007

A simple Windows app showing the distribution of the timings of an Open/Read/Close sequence, here for a Win7-64 system:

include \masm32\MasmBasic\Res\MbGui.asm        ; OPT_Icon Calc
  SetGlobals total, median
  loops=1000
  Dim ms() As DWORD
  For_ ecx=0 To loops-1
        NanoTimer()
        Open "I", #1, "\Masm32\include\Windows.inc"     ; open, read, close
        Let esi=Input$(#1, 4096)
        Close #1
        add total, NanoTimer(us)
        mov ms(ecx), eax
  Next
  ArraySort ms()

Event Paint
  ArrayPlot RgbCol(222, 240, 255)       ; init & set background
  ArrayPlot ms(), 0, lines=3, 00100204h        ; draw the array with 3px lines and left top right bottom margins
  ArrayPlot exit, "Duration of an Open, Read, Close sequence"   ; finish with a title
  GuiTextBox 20.0-60, 60.0, 120, 64, Str$("Bottom 10pc: %i microseconds\n", ms(loops/10))
  GuiTextBox 50.0-60, 60.0, 120, 64, Cat$(Str$("Average: %i microseconds\n", total/loops)+Str$("Median: %i microseconds", ms(loops/2)))
  GuiTextBox 80.0-60, 60.0, 120, 64, Str$("Top 10pc: %i microseconds\n", ms(loops-loops/10))
EndOfCode

jj2007

New version, with more precise timings for the following functions:
- GetHash
- getting 1000 random numbers from CRT rand()
- wRec$(), i.e. translation from Ansi to Unicode of a 100+ chars string
- an Open/Input$/Close sequence

The pattern is very clear, I suppose: 98% of all values are near the median, then there are a few outliers. Source and executables are attached, there is a variable choice=... which allows to build for one of the tests. Building requires MasmBasic 29 Nov 2017.




jimg

For PlotOpenReadClose, I get a bunch of
"The handle is invalid.   eip 0040538E"
until I hit cancel, then it runs.

jj2007

Quote from: jimg on December 01, 2017, 02:07:10 AM
For PlotOpenReadClose, I get a bunch of
"The handle is invalid.   eip 0040538E"
until I hit cancel, then it runs.

Open "I", #1, "\Masm32\include\Windows.inc" ; open, read, close
Let esi=Input$(#1, 4096)  ; yours chokes here <<<<<<<<<<<<<<<<
Close #1


If you launch that exe from your \Masm32 folder, do you still get that box?

jimg

I should have looked at the code.  It works fine on the drive containing the masm32 folder.  I normally run these tests on a separate ram drive.