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
New version, with more precise timings for the following functions:
- GetHash (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1411)
- getting 1000 random numbers from CRT rand()
- wRec$() (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1242), i.e. translation from Ansi to Unicode of a 100+ chars string
- an Open (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1034)/Input$ (http://www.webalice.it/jj2006/MasmBasicQuickReference.htm#Mb1041)/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. (http://masm32.com/board/index.php?topic=94.0)
(http://www.webalice.it/jj2006/pics/GetHash.png)
(http://www.webalice.it/jj2006/pics/CrtRand.png)
(http://www.webalice.it/jj2006/pics/AnsiToUnicode.png)
(http://www.webalice.it/jj2006/pics/OpenReadClose.png)
For PlotOpenReadClose, I get a bunch of
"The handle is invalid. eip 0040538E"
until I hit cancel, then it runs.
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?
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.