Log in

View Full Version : RT_Stats, Compile-time/Runtime Functions v1.43 - 08 Oct 2014


Pages : 1 2 3 [4] 5 6 7 8 9 10 11

StainlessS
4th September 2013, 04:14
RT_Stats v1.23, update. See first post.

v1.23, Mod RT_Debug, added Repeat arg.
Mod RT_YInRangeLocate, added Baffle_W and Baffle_H args.
Added RT_RgbInRange func.
Added RT_RgbInRangeLocate func.


RT_Debug update in Blue:

RT_Debug(string s1, ... , string sn,bool "name"=true,bool "Repeat"=true)
Non-clip function. Takes one or more strings, joins them together and then outputs the combined
string to OutputDebugString(), if strings are NOT space separated, it inserts a single space between them.
Useful during development Compile-time/Run-time scripts to monitor status in real time.
Can also output multiline string obtained via eg RT_ReadTxtFromFile.
Name: bool Default=True. If False, then does NOT output "RT_Debug: " at the beginning of each line, you
might want to replace with your own title in string s1.
Use DebugView utility to view and capture output. http://technet.microsoft.com/en-gb/sysinternals/bb545027
Usage eg:- RT_Debug("["+String(42)+"]","Going pretty good so far @","Line "+String(19))
Would Produce this "RT_Debug: [42] Going pretty good so far @ Line 19"
The above "RT_Debug:" title is present in all RT_Debug() output to the debugview window and you can (in DebugView),
filter out all lines that do not contain "RT_Debug:" so as to skip stuff that is of no interest (eg AVSPMod generates
some output, not sure but I think Avisynth v2.58 also generates lots of debug stuff).
NOTE, Any program can send output to DebugView window, if no debug viewer is present, it normally just disappears
down the plughole.
In DebugView, filter for eg "RT_Debug:" to skip all the extraneous stuff generated by other plugins/programs.
(In DebugView "Menu:Edit-Filter/Highlight", and enter "RT_Debug:".
v1.14, No longer converts characters 127->255 to SPACE, only chars 0->31 (excluding n/l and CR) converted to space.
Characters displayed via debugview are same as those via SubTitle, but those above 127 are dissimilar to the ones
produced via Avisynth source Info.h, used during eg plugin metrics display.
v1.23, Added Repeat arg, only used if Name==False.
If name==False and Repeat==True then outputs first string at beginning of each line, ie shows
your own name on each line where input strings contain Chr(10) line breaks. False output first string on first
line only.


New func RT_RgbInRange

RT_RgbInRange(clip,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false, \
int "RLo"=128,int "RHi"=RLo,int "GLo"=128,int "GHi"=GLo,int "BLo"=128,int "BHi"=BLo)
Returns float value (0.0 -> 1.0) being the amount of pixels with all channels in the range "cLo" to "cHi" (inclusive, c==R or G or B),
1.0 is equivalent to 100%.
NOTE, differs from other funcs that return range 0.0 to 255.0. NOTE, cLo defaults to 128, "cHi" defaults to "cLo".
RLo: Default 128, lower bound of pixel values of Red Channel to search for.
RHi: Default RLo, upper bound of pixel values to Red Channel search for.
GLo: Default 128, lower bound of pixel values of Green Channel to search for.
GHi: Default GLo, upper bound of pixel values to Green Channel search for.
BLo: Default 128, lower bound of pixel values of Blue Channel to search for.
BHi: Default BLo, upper bound of pixel values to Blue Channel search for.


RT_YInRangeLocate, Added Baffle_W, Baffle_H

Function RT_YInRangeLocate(clip c,int "n"=current_frame,int "Delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,int "Baffle"=8,float "Thresh"=0.0, \
int "Lo"=128,int "Hi"=255,Int "Matrix"=(width<=720?2:3),String "Prefix"="YIRL_",bool "Debug"=false,int "Baffle_W"=Baffle,int "Baffle_H"=Baffle)

Clip function to scan frame n+delta for an area where percentage of pixels in luma range Lo to Hi (inclusive) breaks a threshold over at
least Baffle consecutive number of scanlines (all four sides).
Returns True on Successful location else false. On success sets Global var Coords.

RT_YInRangeLocate() tests scanlines from outer most scanlines (h and v), towards inner most, stops where it find Baffle consecutive scanlines
that contain more than Thresh percent of pixels in range Lo to Hi. Object interiors are not tested and so could be hollow.
Would also give +ve result for a disjoint shape like this
--
| |
--
Args:
n: default = current_frame in runtime environment.
Delta: Default = 0
X:Y:W:H: All default=0 as in crop. Area to search, default is full frame.
Baffle: Default=8, minimum number of scanlines that must have a percentage of pixels in range Lo to Hi, greater than Thresh. Avoids noise.
Thresh: Default=0.0 (0.0->100.0). Percentage pixels above which breaks Threshold. Default is any pixel in the range Lo to Hi will break threshold.
Lo: Default 128, lower bound of pixel values to search for.
Hi: Default 255, upper bound of pixel values to search for.
Matrix: Default for RGB is 2(PC601) if width <= 720 else 3(PC709) : YUV not used
Prefix: Default "YIRL_", prefix for Global Var coords set on successful location of object, eg YIRL_X, YIRL_Y, YIRL_W, YIRL_H.
Debug: Default false. If true outputs info to debugView.
Baffle_W, Default Baffle. Thickness of Left and Right side vertical edges, silently limited to width W of search area.
Baffle_H, Default Baffle. Thickness of Top and Bottom horizontal edges, silently limited to height H of search area.


RT_RgbInRangeLocate, new function.

Function RT_RgbInRangeLocate(clip c,int "n"=current_frame,int "Delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,int "Baffle"=8,float "Thresh"=0.0, \
int "RLo"=128,int "RHi"=255,int "GLo"=128,int "GHi"=255,int "BLo"=128,int "BHi"=255, \
String "Prefix"="RGBIRL_",bool "Debug"=false,int "Baffle_W"=Baffle,int "Baffle_H"=Baffle)

Clip function to scan frame n+delta for an area where percentage of pixels in all 3 RGB channels range cLo to cHi (inclusive, c==R or G or B)
breaks a threshold over at least Baffle consecutive number of scanlines (all four sides).
Returns True on Successful location else false. On success sets Global var Coords.

RT_RgbInRangeLocate() tests scanlines from outer most scanlines (h and v), towards inner most, stops where it find Baffle consecutive scanlines
that contain more than Thresh percent of pixels in range cLo to cHi. Object interiors are not tested and so could be hollow.
Would also give +ve result for a disjoint shape like this
--
| |
--
Args:
n: default = current_frame in runtime environment.
Delta: Default = 0
X:Y:W:H: All default=0 as in crop. Area to search, default is full frame.
Baffle: Default=8, minimum number of scanlines that must have a percentage of pixels in range Lo to Hi, greater than Thresh. Avoids noise.
Thresh: Default=0.0 (0.0->100.0). Percentage pixels above which breaks Threshold.
Default is any pixel with all three channels in range cLo to cHi, will break threshold.
RLo: Default 128, lower bound of pixel values of Red Channel to search for.
RHi: Default 255, upper bound of pixel values to Red Channel search for.
GLo: Default 128, lower bound of pixel values of Green Channel to search for.
GHi: Default 255, upper bound of pixel values to Green Channel search for.
BLo: Default 128, lower bound of pixel values of Blue Channel to search for.
BHi: Default 255, upper bound of pixel values to Blue Channel search for.
Prefix: Default "RGBIRL_", prefix for Global Var coords set on successful location of object, eg RGBIRL_X, RGBIRL_Y, RGBIRL_W, RGBIRL_H.
Debug: Default false. If true outputs info to debugView.
Baffle_W, Default Baffle. Thickness of Left and Right side vertical edges, silently limited to width W of search area.
Baffle_H, Default Baffle. Thickness of Top and Bottom horizontal edges, silently limited to height H of search area.


Demo for RT_RgbInRangeLocate()

RED =$AA # Object Color to look for
GREEN =$CC
BLUE =$FF

OBJECT_W = 10 # Object Width
OBJECT_H = 10 # Object Height

AREA_X = 0 # Area of frame to search (0,0,0,0=full frame, As Crop)
AREA_Y = 0
AREA_W = -0
AREA_H = -0

R_MIN = RED R_MAX = RED
G_MIN = GREEN G_MAX = GREEN
B_MIN = BLUE B_MAX = BLUE

# Overlay Converts RGB->YUV->RGB (can set inexact color). Use Layer Instead, MUST set ALPHA
RGBA=((255 * 256 + RED)*256+GREEN)*256+BLUE

COORDINATES="coordinates.txt"

# Fake input clip, for testing # EDIT: Animated fake clip partly liberated from a Cretindesalpes script
a = BlankClip(length=480,width=480,height=480)
b = a.BlankClip(width=OBJECT_W, height=OBJECT_H, color=RGBA)
a.Animate (0, a.FrameCount () - 1, "Layer", b,"add",257, 0, 0, b,"add",257, 479, 479)

NOTFOUND="NOT FOUND"
sep = ", "
Bra = "] "
RT_FileDelete(COORDINATES) # Delete coordinates file
ScriptClip ("""
Bingo=RT_RgbInRangeLocate(x=AREA_X,y=AREA_Y,w=AREA_W,h=AREA_H,
\ RLo=R_MIN,Rhi=R_MAX,GLo=G_MIN,Ghi=G_MAX,BLo=B_MIN,Bhi=B_MAX,Baffle_W=OBJECT_W,Baffle_H=OBJECT_H)
(Bingo) ? WriteFile (COORDINATES,"current_frame", "Bra", "RGBIRL_X", "sep", "RGBIRL_Y")
\ : WriteFile (COORDINATES,"current_frame", "Bra", "NOTFOUND")
""")


EDIT: Note, RT_RgbInRangeLocate() RGB32 and RGB24, however above demo RGB32 Only as Layer only for RGB32.

StainlessS
8th September 2013, 14:08
RT_Stats functions current @ v1.23

There follows a list of all function names together with CPP style argument specifiers that inform
Avisynth the argument types and optional names. Optional arguments have square brackets surrounding
their name as in [name] and are followed by a type specifier character that gives the type.
Unnamed arguments are not optional. eg "cc[arg1]b[arg2]i" would be two compulsory unnamed clip args,
followed by optional 'arg1' of type bool and optional 'arg2' of type int.

# Argument type specifier strings.
c - Video Clip
i - Integer number
f - Float number
s - String
b - boolean
. - Any type (dot)
# Array Specifiers
i* - Integer Array, zero or more
i+ - Integer Array, one or more
.* - Any type Array, zero or more
.+ - Any type Array, one or more
# Etc
###################################

RT_ColorSpaceXMod,"c"
RT_ColorSpaceYMod,"c[Laced]b"
RT_Stats,"c"
RT_GraphLink,"cc+b*"
RT_Subtitle, "cs.*[align]i[x]i[y]i[vcent]b[expx]b[expy]b"
// ------
RT_BitNOT,"i"
RT_BitAND,"ii"
RT_BitOR ,"ii"
RT_BitXOR,"ii"
RT_BitASL,"ii"
RT_BitASR,"ii"
RT_BitLSL,"ii"
RT_BitLSR,"ii"
RT_BitTST,"ii"
RT_BitCLR,"ii"
RT_BitSET,"ii"
RT_BitCHG,"ii"
RT_BitROR,"ii"
RT_BitROL,"ii"
RT_BitSetCount,"i"
// ------
RT_Hex,"i[width]i"
RT_HexValue,"s[pos]i"
RT_NumberString,"i[base]i[width]i"
RT_NumberValue,"s[base]i[pos]i"
// ------
RT_Call, "s[Hide]b[Debug]b"
RT_GetLastError, ""
RT_GetLastErrorString, ""
// ------
RT_Debug, "s+[name]b[repeat]b"
// ------
RT_GetProcessName, "[Parent]b[debug]b"
// ------
RT_Undefined,""
RT_VarExist,"s"
RT_Ord,"s[pos]i"
RT_Timer,""
// ------
RT_FileQueryLines,"s"
RT_ReadTxtFromFile,"s[Lines]i[Start]i"
RT_WriteFileList,"ss[append]b"
RT_TxtWriteFile,"ss[append]b"
RT_FileDelete,"s"
//
RT_FSelOpen ,"[title]s[dir]s[filt]s[fn]s[multi]b[debug]b"
RT_FSelSaveAs,"[title]s[dir]s[filt]s[fn]s[debug]b"
RT_FSelFolder,"[title]s[dir]s[debug]b"
// ------
RT_YDifference,"c[n]i[delta]i[x]i[y]i[w]i[h]i[x2]i[y2]i[Interlaced]b[matrix]i"
RT_LumaCorrelation,"cc[n]i[delta]i[x]i[y]i[w]i[h]i[n2]i[delta2]i[x2]i[y2]i[Interlaced]b[matrix]i"
RT_LumaDifference,"cc[n]i[delta]i[x]i[y]i[w]i[h]i[n2]i[delta2]i[x2]i[y2]i[Interlaced]b[matrix]i"
RT_LumaSceneChange,"cc[n]i[delta]i[x]i[y]i[w]i[h]i[n2]i[delta2]i[x2]i[y2]i[Interlaced]b[matrix]i" \
"[Bias]f[Gain]f[Cont]f[RPow]f[SPow]f[SPMid]f[Pord]b"
RT_LumaMovement,"cc[n]i[delta]i[x]i[y]i[w]i[h]i[n2]i[delta2]i[x2]i[y2]i[Interlaced]b[matrix]i[mode]i[blkw]i[blkh]i" \
"[Bias]f[Gain]f[Cont]f[RPow]f[SPow]f[SPMid]f[Pord]b"
//
RT_YPlaneMin, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[matrix]i"
RT_YPlaneMax, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[matrix]i"
RT_YPlaneMinMaxDifference, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[matrix]i"
RT_YPlaneMedian, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[matrix]i"
RT_AverageLuma, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[matrix]i"
RT_YPlaneStdev, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[matrix]i"
RT_YInRange, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[matrix]i[lo]i[hi]i"
RT_YStats, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[matrix]i[lo]i[hi]i[flgs]i[prefix]s"
///
RT_RgbChanMin, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i"
RT_RgbChanMax, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i"
RT_RgbChanMinMaxDifference, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i"
RT_RgbChanMedian, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i"
RT_RgbChanAve, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i"
RT_RgbChanStdev, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i"
RT_RgbChanInRange, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Chan]i[lo]i[hi]i"
RT_RgbChanStats, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[threshold]f[Chan]i[lo]i[hi]i[flgs]i[prefix]s"
///
RT_RGB32AsFloat,"c[n]i[delta]i[x]i[y]i"
RT_RGB32AsInt,"c[n]i[delta]i[x]i[y]i"
RT_FloatAsRGBA,"f"
///
RT_YankChain, "c[n]i[delta]i"
// ------
RT_TxtQueryLines,"s"
RT_TxtGetLine,"s[Line]i"
RT_StrAddStr,"ss+"
RT_TxtAddStr,"ss+"
RT_QuoteStr,"s"
RT_StrReplace,"sss[sig]b"
RT_StrReplaceDeep,"sss[sig]b"
RT_StrReplaceMulti,"sss[sig]b"
RT_StrPad,"si[c]s"
RT_FindStr,"ss[sig]b[pos]i"
// ------
RT_TxtSort,"s[mode]i"
// ------
RT_GetWorkingDir,""
RT_FilenameSplit,"s[get]i"
RT_GetFileExtension,"s"

// ------
RT_QueryLumaMinMax,"c[Samples]i[Ignore]f[Prefix]s[Debug]b[X]i[Y]i[W]i[H]i[Matrix]i"
RT_QueryBorderCrop,"c[Samples]i[Thresh]f[Laced]b[xMod]i[yMod]i[wMod]i[hMod]i[Relative]b[Prefix]s[RLBT]i[Debug]b[Ignore]f[Matrix]i" \
"[ScanPerc]f[Baffle]i[ScaleAutoThreshRGB]b[ScaleAutoThreshYUV]b"
RT_YInRangeLocate, "c[n]i[delta]i[x]i[y]i[w]i[h]i[baffle]i[thresh]f[lo]i[hi]i[matrix]i[prefix]s[debug]b[baffle_w]i[baffle_h]i"
// ------
RT_RgbInRange, "c[n]i[delta]i[x]i[y]i[w]i[h]i[Interlaced]b[Rlo]i[Rhi]i[Glo]i[Ghi]i[Blo]i[Bhi]i"
RT_RGBInRangeLocate,"c[n]i[delta]i[x]i[y]i[w]i[h]i[baffle]i[thresh]f[Rlo]i[Rhi]i[Glo]i[Ghi]i[Blo]i[Bhi]i[prefix]s[debug]b" \
"[baffle_w]i[baffle_h]i"
// ------
RT_GetSAR, "cf"
RT_GetDAR, "cf"
RT_SignalDAR, "f"
RT_GetCropDAR,"cf[x]f[y]f[w]f[h]f"

StainlessS
8th September 2013, 20:23
@Jmac698

If you see this (I saw you scurrying around last night :p ),
try out RgbAmplifier on your Moon2 set (after PlanetCrop,
with/without PlanetCrop luma leveling), and with/without
speedup to eg 7FPS (clearly shows clouds moving across the
moon images). Makes for some interesting shots.

jmac698
9th September 2013, 03:12
interesting, will do! Funny, I was just reading about that exact topic at random and thinking about uses for exaggerating differences, and in fact there's a much more sophicated way to do this
http://people.csail.mit.edu/mrub/vidmag/

Forensic
9th September 2013, 05:41
Jmac698, don't be hatin on my RgbAmplifier. I invented this in 2010 but could not use it on anything except small short test videos due to out of memory errors. I brought it back to life when RTStats introduced a new tool and, with the talents on StainlessS and Gavino, it became a very useable plug. Eulerian Video Magnification also lets you limit the affected color range but I think it is designed for clear high-res high-fps videos. RgbAmplifier is designed to work on noisy low-res low-fps videos (like surveillance videos). It is proving to be quite useful for my fellow video forensic analysts.

StainlessS
9th September 2013, 19:08
Very interesting link JMac.
Limited use though due to no motion requirement, lie detector, baby not breathing alarm, perhaps some kind of strain gauge.
Dont bother trying RgbAmplifier on your original Moon set, looks appalling mulicolored mess with full amp of 10.0.

EDIT: Forensic, I tried RGBAmplifier on the Face.mp4 with radius between about 7 to 25, it does actually reveal the
same facial flush of the vidmag link, it does however reveal compression artifacts and all minute differences, and does not
look anywhere near as good as vidmag. Not really surprising though as vidmag has a different purpose.
I also did a quick hack and tried magnifying difference between current frame and the average of
(current-off)+(current+off) with off of about 13 frames, even that worked quite well but again was quite noisy.

Forensic
10th September 2013, 08:24
I believe that they simply came to a similar methodology as RgbAmplifier. I also propose that RgbAmplifier results would match theirs (for color variance detection) in clarity if they had provided the uncompressed version of Face.mp4. By sharing a h.264 version, the file has quantization data errors (the noise) and significant pixel disruptions at he boundaries of the slices (aka, pixel blocks). No way to know for sure without that file.

StainlessS
10th September 2013, 18:58
I also did a quick hack (now deleted) where I used ClipBlend(delay=0) [blend ALL frames encountered] and saved last frame.
Called RGBAmp hack version with only args Magnifier and new arg clip c2 (the whole clip blended frame) and amplified diff
between current frame and the single blended frame. Still amp'ed the face flush and also minute differences as face moved
with hair going strangely wiry, and reduced quantization anomalies.
Would have been nice to have original uncompressed source to try for comparison, but I think they must also have some kind of
temporal smoothing with frames close to current and perhaps at 'beat' distance from current.
I did not yet read their source, think I'll stop with those experiments.

StainlessS
28th September 2013, 18:26
RT_Stats v1.24, new version, see 1st post.

v1.24, Fixed Interlaced Y stepping.
Added Mask args to Y/RGB stats, Added RT_YPNorm, RT_RgbChanPNorm (*** EXPERIMENTAL ***)
Added RT_TxtFindStr and RT_FileFindStr and RT_String.

New Functions added.


v1.24, New.
RT_TxtFindStr(String S,string FndS,bool "Sig"=True,int "Pos"=1,int "Start"=0,int "Lines"=0)
Finds unnamed string FndS in unnamed multi-line text string S, starting at line 'Start' and searching 'Lines' number of string lines.
S: is a multi-line text string, ie a newline [CHR(10)] separated list of strings.
FndS: is a single string and will be considered terminated early at the first carriage return [Chr(13)] or newline [Chr(10)],
carriage returns and newlines will not be findable using this function.
Sig: Default=True, does case significant comparison, insignificant if false.
Pos: Default=1, is the character start position in an individual line of the multi-line string S to start searching
for the FndS string. Allows you to skip search on first Pos-1 characters within all single lines of multi-line string S.
If Pos less than 1, then will return -ve number (usually -1), Not Found.
Start: Default 0, is the 0 relative starting line where the searching begins within the multi-line string S.
Lines: Default 0(all lines). Number of lines in multi-line string to seach, starting at line 'Start'.
A -ve return is 'Not Found'. On success returns the line number of the first instance of a found string in the Start and Lines
range of lines. An empty "" FndS will always return -ve result, ie Not Found (as will all errors).
see RT_TxtQueryLines, to inquire number of single lines in a chr(10) separated multi-line string.
see RT_TxtGetLine to extract a single line from a multi-line string [without trailing Chr(10) or Chr(13)].
NOTE, Character position 'Pos' is 1 relative whereas multi-line line 'Start' index is 0 relative.



v1.24, New
RT_String(String format, dat1,...,datn,int "Esc"=1)

Returns a formatted string. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the text string that is
returned, uses C/CPP printf() style formatting.
Format: compulsory string controlling format and describing the datn type args that are expected.
datn: Variable number of data args of any type (excluding clip).
Esc: Default 1, converts embedded escape sequences in format string, 2 convert escape sequences in both format and datn strings,
0 no escape sequence conversion done.
It is necessary to specify the "Esc" name if you wish to alter default, as Avisynth cannot tell when the variable number of data datn
args ends.
You might wish to turn off escape conversion if you want to send a multi-line string to Subtitle() without conversion of '\n' to Chr(10).

printf Format spec here:- http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx
NOTE, the only support for printing Bool variables is %s as string, ie prints "True" or "False".
Formatting supported %[flags] [width] [.precision] type
flags, one of "-,+,0, ,#"
width, integer, "*" supported (width supplied via dat arg).
Precision, integer, "*" supported (precision supplied via dat arg).
type,
"c,C,d,i,o,u,x,X", Integer type, c,C=character, d,i=signed, o,u,x,X=unsigned (o=octal, x=Hex).
"e,E,f,g,G", Floating point type
"s,S", String type (also Bool).

Formatting Insertion point is marked with '%' character (as in Avisynth String function), if you wish to use a percent
character within the returned string, it should be inserted twice ie '%%' will produce a single '%'.
EDIT: '%' in data datn arg strings do not need double % character.

A Backslash character '\' introduces escape sequences, to insert a backslash character itself, you must supply a double
backslash sequence ie '\\'.
When 'Esc' is non zero, converts embedded escape character sequences (Case Significant):-
'\\' Converted to '\' Single Backslash
'\n' Converted to Chr(10) NewLine
'\r' Converted to Chr(13) Carriage Return
'\t' Converted to Chr(9) Horizontal TAB
'\v' Converted to Chr(11) Vertical TAB
'\f' Converted to Chr(12) FormFeed
'\b' Converted to Chr(8) BackSpace
'\a' Converted to Chr(7) Bell
'\x', where x is ANY OTHER CHARACTER not included above, will be copied verbatim, ie '\x'.

eg
RT_String("Hello there %s and %s.\nGoodbye %d.","Fred","Ted",2013)
would return same as:- "Hello there Fred and Ted." + Chr(10) + "Goodbye 2013."

Be aware that when 'Esc'=2, the string is constructed via two passes, the 1st pass inserts the data args into the format string,
2nd pass converts escape sequences, so the escape sequences could also exist in the datn args. Also, beware of constructing strings
which when joined together, form an escape sequence.
Take care when handling filenames with path backslash, suggest using 'Esc'=1 when data datn strings contain eg Filenames.



v1.24, New.
RT_FileFindStr(String FileName,string FndS,bool "Sig"=True,int "Pos"=1,int "Start"=0,int "Lines"=0)
Finds unnamed string 'FndS' in 'FileName' text file, starting at line 'Start' and searching 'Lines' number of text lines.
FileName: Name of a file containing text to search.
FndS: is a string and will be considered terminated early at the first carriage return [Chr(13)] or newline [Chr(10)], carriage returns
and newlines will not be findable using this function.
Sig: Default=True, does case significant comparison, insignificant if false.
Pos: Default=1, is the character start position in an individual line of text to start searching for the FndS string.
Allows you to skip search on first Pos-1 characters within all lines of text.
If Pos less than 1, then will return -ve number (usually -1), Not Found.
Start: Default 0, is the 0 relative starting line where the searching begins in the text file.
Lines: Default 0(all lines). Number of lines text to seach, starting at 'Start' line.
A -ve return is 'Not Found'. On success returns the line number of the first instance of a found string in the Start and Lines
range of lines. An empty "" FndS will always return -ve result, ie Not Found.
see RT_FileQueryLines, to inquire number lines in a text file.
see RT_ReadTxtFromFile to extract a range of lines from a text file.
NOTE, Character position 'Pos' is 1 relative whereas multi-line line 'Start' index is 0 relative.




RT_YPNorm(clip c,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1,int "Matrix"=(width<=720?2:3),clip "mask"=NOT_USED,int "MaskMin"=128,"MaskMax"=255)
Return int -1 if no valid pixels in Mask clip.
Returns FLOAT value greater or equal to 0.0, being the "Minkowski P-norm" (range depends upon values of 'd' and 'u') for frame(n+delta)
area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA)
mu, Float, default 0.0 (0.0 -> 255.0)
d, int, default 1 (1 -> 255) # downscale
p, int, default 1 (1 -> 16) # power
u, int, default 1 (1 -> 255) # final upscale before returning result (experimental)
Formula is: sum_over_pixels[ ((pixel-mu)/d)^p ]^(1/p) * u
or in words: d and u are scaling aids. The differences between the pixel values and mu are scaled, taken to the power of p and added up
over the frame. The sum is taken to the p-th root and finally rescaled.
mu=0, d=1, p=1, u=1 yields the average.
mu=average, d=1, p=2, u=1 yields the standard deviation (uncorrected sample standard deviation).
Implemented as requested by Martin53 (thankyou). *** EXPERIMENTAL ***
http://en.wikipedia.org/wiki/P-norm#The_p-norm_in_finite_dimensions
http://en.wikipedia.org/wiki/Minkowski_distance



RT_RgbChanPNorm(clip c,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
int "chan"=0,float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1,int "mask"=NOT_USED, int "MaskMin"=128,"MaskMax"=255)
Return int -1 if no valid pixels in Mask clip.
Returns FLOAT value greater or equal to 0.0, being the "Minkowski P-norm" (range depends upon values of 'd' and 'u') for frame(n+delta)
area x,y,w,h, and selected Chan channel (0=R,1=G,2=B, RGB32 3=ALPHA)
mu, Float, default 0.0 (0.0 -> 255.0)
d, int, default 1 (1 -> 255) # downscale
p, int, default 1 (1 -> 16) # power
u, int, default 1 (1 -> 255) # final upscale before returning result (experimental)
Formula is: sum_over_pixels[ ((pixel-mu)/d)^p ]^(1/p) * u
or in words: d and u are scaling aids. The differences between the pixel values and mu are scaled, taken to the power of p and added up
over the frame. The sum is taken to the p-th root and finally rescaled.
mu=0, d=1, p=1, u=1 yields the average.
mu=average, d=1, p=2, u=1 yields the standard deviation (uncorrected sample standard deviation).
Implemented as requested by Martin53 (thankyou). *** EXPERIMENTAL ***
http://en.wikipedia.org/wiki/P-norm#The_p-norm_in_finite_dimensions
http://en.wikipedia.org/wiki/Minkowski_distance


NOT NEW but extended for mask, similar changes for RT_YStats, doc not shown.
EDIT: INSERTED THIS CODE BLOCK

********************************************
********* RGB MASKED Channel FUNCTIONS *****
********************************************

RGB32, RGB24 source clip.

The source clip c must be RGB32 or RGB24.

The compiletime/runtime clip functions share some common characteristics.
The 'n' and (where used) 'n2' args are the optional frame numbers and default to 'current_frame' if not specified.
The x,y,w,h, coords specify the source rectangle under scrutiny and are specified as for Crop(), the default 0,0,0,0 is full frame.
If 'interlaced' is true, then every other line is ommited from the scan, so if eg x=0,y=1, then scanlines 1,3,5,7 etc are scanned,
if eg x=0,y=4 then scanlines 4,6,8,10 etc are scanned. The 'h' coord specifies the full height scan ie same whether interlaced is true
or false, although it will not matter if the 'h' coord is specified as eg odd or even, internally the height 'h' is reduced by 1 when
interlaced=true and 'h' is even.

Optional mask clip Planar ONLY [v2.6 colorpspaces OK]
The Planar mask clip, governs which pixels are processed by the functions. Where a luma pixel in selected area of the the mask clip is
in range "MaskMin" to "MaskMax" inclusive, then those pixels will be processed.
Mask MUST, be same dimensions and have at least the same number of frames as clip c.
Calling without mask OR with MaskMin=0,MaskMax=255 will effectively ignore the mask and scan full x,y,w,h area.

The Chan arg specifies which R or G or B channel to process [the multi-functional RT_RgbChanStats() function also allows a Chan arg of -1,
which processes R and G and B simulaneously for all functions selected by flgs arg, also allowed is chan arg of -2 which additionally
processes the ALPHA channel if RGB32 but throws an error if RGB24].
Default Chan is 0 (Red), 1 = Green, 2=Blue channel and 3=ALPHA channel when RGB32 ONLY else error.




RT_RgbChanStats(clip c,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
float "threshold"=0.0,int "chan"=0,int "lo"=128,int "hi"=lo,int "flgs"=255,string "prefix"="RCS_",
float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1,int "mask"=NOT_USED, int "MaskMin"=128,"MaskMax"=255)
Returns multiple results as for above single frame RGB channel sampling functions as Global Variables (prefixed with the prefix string arg).
The args up to "interlaced", are as for all other clip functions, "threshold" used only for "RT_RgbChanMin", "RT_RgbChanMax" and
"RT_RgbChanMinMaxDifference" equivalent routines with same functionality.
"lo" and "hi" are used only with the "RT_RgbChanInRange" equivalent routine with same functionality.
"mu" and "d" and "p" and "u" are used only with the "RT_RgbChanPNorm" equivalent routine with same functionality.
The new arg "Flgs" selects which results you want returned and the string "Prefix" that is prepended
to the returned global variable names.
The actual return result is a copy of the flgs args with any non valid bits reset, ie the global variables that were set.
Global variables are NOT altered for any function not selected in flgs.
Returns 0 if no pixels found in search area of mask within MaskMin and MaskMax.

Flgs_Bit_Number Add_To_Flgs Equivalent_Function Global_Var_Set_Excluding_Prefix_and_Chan_postfix
0 1($01) RT_RgbChanMin() "Min" (0->255)
1 2($02) RT_RgbChanMax() "Max" (0->255)
2 4($04) RT_RgbChanMinMaxDifference() "MinMaxDiff" (0->255)
3 8($08) RT_RgbChanMedian() "Med" (0->255)
4 16($10) RT_RgbChanAve() "Ave" (0.0->255.0)
5 32($20) RT_RgbChanStdev() "Stdev" (0.0->255.0)
6 64($40) RT_RgbChanInRange() "InRng" (0.0->1.0)
7 128($80) RT_RgbChanPNorm() "PNorm" (0.0->??? depends upon d and u)
The Channel Postfix is of the form "_0", where 0 is RED, 1 is GREEN and 2 is Blue, 3 is ALPHA(RGB32 ONLY), and is appended to the
base name described above. So eg RT_RgbChanMin for RED channel 0 with default Prefix is "RCS_Min_0".
RT_RgbChanstats() allows you to inquire multiple results simultaneously, with not much more overhead than calling a single individual
routine, however, you should not select sub functions that you dont need as there may be an additional unnecessary overhead.
The Default flgs=255($FF) are all bits set and so sets ALL global vars at once.
RT_RgbChanStats(flgs=1+2+16) would set global vars "RCS_Min_0", "RCS_Max_0" and "RCS_Ave_0" for full frame current_frame, Red Channel.

In addition to above Global Variables, RT_RgbChanStats() sets an int Global variable (where default prefix) of "RCS_PixelCount_0" being
the number of Red Channel pixels in mask area X,Y,W,H between MaskMin and MaskMax inclusive.

NOTE, RT_RgbChanStats() allows Chan to be -1, where ALL three R, and G, and B channels are processed simultaneouly for ALL functions
selected by flgs arg (ALPHA Channel is NOT processed).
A chan arg of -2 (RGB32 ONLY allowed) will additionally process the ALPHA channel as well as R+G+B.
Also Note, (where default Prefix) RCS_PixelCount_x is also set (identically) for all channels when Chan == -1 or -2.

StainlessS
28th September 2013, 19:00
Short lived v1.24 posted above, have decided to change RT_String() Esc arg to int, 0 = no escape conversion, 1 = conversion only in format string,
2 = convert escape sequences in both format string and inserted data strings, default 1.

Will update zip on mediafire soon. (dont bother downloading v1.24).

StainlessS
28th September 2013, 20:13
Short lived v1.24 updated to v1.25, Changed RT_String Esc arg to type int. See 1st post.

2nd Code block two posts previous updated.

EDIT: This may or may not be my last ever post on the D9.

EDIT:
Life intercedes and well, cannot buck life. If I should not resurect, then would be most happy
if others would take it upon themselves to continue the daft stuff done already.
Peace Bro's.

EDIT: Ok, hence forth, just watching, not particating in general everyday stuff, just not making so much noise, thats all.

raffriff42
30th September 2013, 12:10
Thanks for everything, StainlessS, wherever you are :thanks: :thanks: :thanks: :thanks:

martin53
13th October 2013, 19:13
StainlessS, can you please help,
RT_RgbChanStats(cRGB, mask=c24, Chan=-1, threshold=MINMAX_THRESH, flgs=$90, prefix="fRGB2_", MaskMin=max(fY_yMax-ydif,1), MaskMax=ymax, d=255, u=255, p=power)
fNorm = 1.0/(KR*fRGB2_PNorm_0 + KG*fRGB2_PNorm_1 + KB*fRGB2_PNorm_2)

throws the error (DebugView, through try... catch... function)
[7540] RT_Debug: [...] I don't know what "fRGB2_PNorm_0" means

chan=0 does not help. RT_Stats() is "v1.25 - 28 Sept 2013"

MYStats.dll (V1.06),

MRGBChanStats(cRGB, c24, Chan=-1, threshold=MINMAX_THRESH, flgs=$90, prefix="fRGB2_", MaskMin=max(fY_yMax-ydif,1), MaskMax=ymax, d=255, u=255, p=power)
fNorm = 1.0/(KR*fRGB2_PNorm_0 + KG*fRGB2_PNorm_1 + KB*fRGB2_PNorm_2)

works fine.

StainlessS
14th October 2013, 02:58
M53, shall sort it out whatever it is.
Sorry for the problem.

StainlessS
15th October 2013, 22:20
RT_Stats v1.26, see 1st post.

martin53
16th October 2013, 20:41
StainlessS,
:thanks: :)

As I learned from the AWB thread, the following is a designed feature:
With the example script,
c = ColorBars(pixel_type="YV24")
cRGB = c.ConvertToRGB(matrix="PC.601")
c.GScriptClip("GScript("+chr(34)+chr(34)+chr(34)+""" # "
Try {
c = last
for (i=16, 235) {
RT_RgbChanStats(cRGB, mask=c, Chan=-1, threshold=0, flgs=$10, prefix="fRGB_i_", MaskMin=i, MaskMax=i)
RT_Debug(RT_String("i %d %d, R %f, G %f, B %f", i, fRGB_i_Pixelcount_0, fRGB_i_Ave_0, fRGB_i_Ave_1, fRGB_i_Ave_2))
}
c
} catch(err) {
RT_Debug("GScriptClip ", err)
return last
}
"""+chr(34)+chr(34)+chr(34)+")", after_frame=true, args="cRGB") #"

DebugView shows, that the three variables stay unchanged for the many brightness values not contained in the mask.
When the starting value i is reduced to 15, the error occurs:
[5672] RT_Debug: GScriptClip I don't know what "fRGB_i_Ave_0" means

To avoid script errors, the user can put a global fRGB_i_Ave_0 = 0.0 etc. before the RT_RgbChanStats() call. But it must be a global var, otherwise the thereby created local var will occlude the global var, which is a strange effect when not understood.

StainlessS
17th October 2013, 13:40
From this thread:http://forum.doom9.org/showthread.php?p=1648164#post1648164
OK, fine with everything,
was confused a bit with the handling of variables and posted a question in the RT_Stats thread.
When existing variables are unaltered in the case of pixelcount==0, I need to set them to a neutral value in advance. Say I use chan=-1 then I can not know in advance whether all three channels will return data - although I'd think if one channel does, all channels should.
My observation was that when I initialize variables before I call RT_RgbChanStats, the function does not change them.
I observed some non-credibly low averages with real world footage, but was retarded with my tests by the variables thing.
Maybe I confused the system with local over global variables. Will check that.
However, the whole thing is a bit tricky to master, I think, for newbies, and maybe it should be redesigned a bit.

OK, I should labour the Global Var point in docs and note the specific behaviour.
In the case of chan == -1, all three pixelcounts are zeroed when no valid pixels found in mask, in the case of individual
channel number, only the relevant channel pixelcount is zeroed. On any call, all relevant pixel counts would be identical,
multiple pixelcounts (1 per channel) were deemed better so as to avoid possibility of user having to temporary store eg
red pixelcount when calling for eg Blue channel using different mask.
Myself I would take an Else code path when RT_RgbChanStats returns 0, but I could set pertinent Global vars to -1
if that is your requirement. I would prefer to keep as Global (and in this case cannot change existing behaviour to local),
and yes it can be tricky and awkward having to use 'Global var = whatever'.
You want ALL relevant Global vars to be set to -1 (int) when no valid pixels found in mask ? (excluding pixelcounts).

EDIT: If using an else code path, then would not require try/catch in above previous post.
Result of RT_RgbChanStats/MRgbChanStats are bit flags of which variables were set, 0 == nothing was set.
The only time you can ignore resulting bit flags is when calling function maskless where all pixels in selected area are valid.
I think it might be better to keep as it is without setting 'unset' variables to -1, and use the result bit flags to see if
variables are valid, it might also perhaps help locate coding errors so long as you DONT wrap in try/catch, whereas
setting 'unset' vars to -1 might tend to conceal coding errors.

c = ColorBars(pixel_type="YV24")
cRGB = c.ConvertToRGB(matrix="PC.601")
c.GScriptClip("GScript("+chr(34)+chr(34)+chr(34)+""" # "
c = last
for (i=16, 235) {
Bingo = RT_RgbChanStats(cRGB, mask=c, Chan=-1, threshold=0, flgs=$10, prefix="fRGB_i_", MaskMin=i, MaskMax=i)
if(Bingo!=0) { # EDIT: Could also use eg (fRGB_i_Pixelcount_0 != 0) instead of Bingo
RT_Debug(RT_String("i %d %d, R %f, G %f, B %f", i, fRGB_i_Pixelcount_0, fRGB_i_Ave_0, fRGB_i_Ave_1, fRGB_i_Ave_2))
} Else {
RT_Debug(RT_String("i %d No Valid Pixels",i))
}
c
"""+chr(34)+chr(34)+chr(34)+")", after_frame=true, args="cRGB") #"


1st time I've seen usage of RT_String by someone else, much nicer and less tedious than lots of String() concatenation,
especially with String(x,"%6.2f") style fomatting.
Think I might do a RT_DebugF() type func to avoid having to call RT_Debug with temporary RT_String().

PS, Love your

"GScript("+chr(34)+chr(34)+chr(34)+"""
...
"""+chr(34)+chr(34)+chr(34)+")"

did you devise it yourself ?

EDIT: Is this good enough for your high standards ?

RT_RgbChanStats(clip c,int "n"=current_frame,int "delta"=0,int "x"=0,int "y"=0,int "w"=0,int "h"=0,bool "interlaced"=false,
float "threshold"=0.0,int "chan"=0,int "lo"=128,int "hi"=lo,int "flgs"=255,string "prefix"="RCS_",
float "mu"=0.0,int "d"=1,int "p"=1,int "u"=1,int "mask"=NOT_USED, int "MaskMin"=128,"MaskMax"=255)
Returns multiple results as for above single frame RGB channel sampling functions as Global Variables (prefixed with the prefix string arg).
The args up to "interlaced", are as for all other clip functions, "threshold" used only for "RT_RgbChanMin", "RT_RgbChanMax" and
"RT_RgbChanMinMaxDifference" equivalent routines with same functionality.
"lo" and "hi" are used only with the "RT_RgbChanInRange" equivalent routine with same functionality.
"mu" and "d" and "p" and "u" are used only with the "RT_RgbChanPNorm" equivalent routine with same functionality.
The new arg "Flgs" selects which results you want returned and the string "Prefix" that is prepended
to the returned global variable names.
The actual return result is a copy of the flgs args with any non valid bits reset, ie the global variables that were set.
Global variables are NOT altered for any function not selected in flgs.
Returns 0 if no pixels found in search area of mask within MaskMin and MaskMax.

Flgs_Bit_Number Add_To_Flgs Equivalent_Function Global_Var_Set_Excluding_Prefix_and_Chan_postfix
0 1($01) RT_RgbChanMin() "Min" (0->255)
1 2($02) RT_RgbChanMax() "Max" (0->255)
2 4($04) RT_RgbChanMinMaxDifference() "MinMaxDiff" (0->255)
3 8($08) RT_RgbChanMedian() "Med" (0->255)
4 16($10) RT_RgbChanAve() "Ave" (0.0->255.0)
5 32($20) RT_RgbChanStdev() "Stdev" (0.0->255.0)
6 64($40) RT_RgbChanInRange() "InRng" (0.0->1.0)
7 128($80) RT_RgbChanPNorm() "PNorm" (0.0->??? depends upon d and u)
The Channel Postfix is of the form "_0", where 0 is RED, 1 is GREEN and 2 is Blue, 3 is ALPHA(RGB32 ONLY), and is appended to the
base name described above. So eg RT_RgbChanMin for RED channel 0 with default Prefix is "RCS_Min_0".
RT_RgbChanstats() allows you to inquire multiple results simultaneously, with not much more overhead than calling a single individual
routine, however, you should not select sub functions that you dont need as there may be an additional unnecessary overhead.
The Default flgs=255($FF) are all bits set and so sets ALL global vars at once.
RT_RgbChanStats(flgs=1+2+16) would set global vars "RCS_Min_0", "RCS_Max_0" and "RCS_Ave_0" for full frame current_frame, Red Channel.

In addition to above Global Variables, RT_RgbChanStats() sets an int Global variable (where default prefix) of "RCS_PixelCount_0" being
the number of Red Channel pixels in mask area X,Y,W,H between MaskMin and MaskMax inclusive.

NOTE, RT_RgbChanStats() allows Chan to be -1, where ALL three R, and G, and B channels are processed simultaneouly for ALL functions
selected by flgs arg (ALPHA Channel is NOT processed).
A chan arg of -2 (RGB32 ONLY allowed) will additionally process the ALPHA channel as well as R+G+B.
Also Note, (where default Prefix) RCS_PixelCount_x is also set (identically) for all channels when Chan == -1 or -2.
NOTE, If no valid flg bits set (eg $FF00), then returns 0, RCS_PixelCount_x and all other variables remain as before call.
Assuming some valid flg bits, if no valid pixels were found in mask then function returns 0, and only RCS_PixelCount_x would be set
to 0, no other variables are touched (remain as before call, undefined if not previously existing).
ALSO NOTE, variables are GLOBAL vars, if you set similarly named variables prior to call but without using 'Global' eg
RCS_PixelCount_0 = -1, then this local variable name will hide the Global variable of the same name,
it should be eg Global RCS_PixelCount_0 = -1. See Global Variables here:- http://avisynth.nl/index.php/Script_variables
Example usage:
Scriptclip("""
got = RT_RgbChanStats(c,mask=Mask,chan=-1,flgs=$10) # Ave
(got != 0)
\ ? RT_Debug(RT_String("AveR = %f AveG = %f AveB = %f Pixels = %d",RCS_Ave_0,RCS_Ave_1,RCS_Ave_2,RCS_PixelCount_0))
\ : RT_Debug("NO VALID PIXELS FOUND")
""")

martin53
17th October 2013, 18:04
I would vote for global vars always written and even 0 instead of -1 because that is widely known init behaviour, but can live with all kinds. The user can store previous results somewhere else, I see no good reason for keeping the previous result when it does not fit to the latest parameters anyway. Is there a time save advantage?
Have some concern, that the nonexistent/global/local context might be too much for sporadic/new scripters, too. And it might throw unexpected errors as well with published scripts, I feel. Requires a lot of thought to make scripts work under any thinkable circumstances (footage).

(Bingo!=0) is tidier than (Prefix_Pixelcount_Channel), will adopt that.

The skeleton
GScriptClip("GScript("+chr(34)+chr(34)+chr(34)+""" # "
Try {
c = last
...
} catch(err) {
RT_Debug("GScriptClip ", err)
return last
}
"""+chr(34)+chr(34)+chr(34)+")", args="...") #"
is just my standard template for all runtime environments, the Try...catch had nothing to do with the RT_RgbChan function, just meant to give a useful error message in DebugView in case of script error.
It is a bit harder to locate error line numbers with this skeleton, but else much more convenient because GScript is always at hand. Fiddled out the chr(34)+... with the FSubstitute() script (which btw is also unfinished work because the SVPflow adaption does not yet yield good effect; there even were times when I wondered if I should ask Gavino to combine the two brilliant and helpful GScript and GRunt plugins). I don't like it too much. It came as an act of desperation when I was unable to get TeX-style quotes working. The V2.60 manual says: "The manual used to mention TeX-style quotes, but it has been confirmed that AviSynth doesn't work this way since v1.03" and that's true, so so true, ...
The Try...catch construct came when AWB just returned the unaltered input clip without showing any error - because the error dis not occur in the visible clip processing, but in a helper clip processing. I'm talking of the kind of error messages that do not crash te clip but just show up like a subtitle.
RT_String - fully agree! It's worth reading the RT_Stats doc ;) I can only encourage you with the RT_DebugF() function.

Is it a concept principle of AviSynth, that variables by reference are impossible? Else that would be certainly a preferable way to return more than 1 scalar base type. Although I can propose an alternative: The RT_RgbChanStats and other similar functions could return a n by 1 pixel RGBA clip, and with the help of the weird function RT_RGB32AsFloat(), n real-type vars can be extracted. I mention this because the time save option requires global vars, and global vars mean that only one instance of AWB can be used in a script - except with big effort: transfer the prefixes as string parameters to the instances instead of using a hard coded string. This makes scripts hard (impossible) which e.g. use two different AWB parameter sets to display results side by side and compare.

(Btw hope my english is not impolite or too buggy. You learn some vocabulary and grammar in school, but not to express yourself - please no flattery in response)

EDIT yes, it's good - for those who read the manual ;)

StainlessS
17th October 2013, 19:27
Is it a concept principle of AviSynth, that variables by reference are impossible?

Think so yes, guess big G could answer that with authority.

OK, you convinced me about changing to local vars with the 'two different AWB parameter sets' argument, have not seen any
scripts that rely on Global var status.
However, am most reluctant to set invalid vars to anything that could be valid results, better to know if there are problems in a script
than to hide them. For the same reason I never eg correct invalid coordinates, that kind of thing can hide coding errors for decades.
The only thing worse than that is eg string buffer allocation, forgetting to add 1 to strlen() in C, which due to optimizations in the
Standard C Library may also escape notice for decades until an unusual condition occurs. The Standard C library will return the next
higher multiple of 8 bytes (32 bit m/c) so forgetting to add 1 to short strings will hide the error, will only be revealed when malloc of
exact multiple of 8 is requested and when multiple of 8 + 1 is actually required. An example might be a 'Title' string in a database,
'Mr', 'Mrs', 'Doctor' will escape notice for perhaps decades, and then one day you enter 'Princess' and bang, corruption creeping
through the database until noticed, and finding the bug will be a horrendous experience.

It will also be a little slower if unnecessary setting of invalid vars, you can always preset the vars to whatever value you like
before the call (and it will not be my fault if you use those invalid values).

Shall do mod to local vars now and do the RT_DebugF() thing too.

StainlessS
17th October 2013, 22:57
New Version RT_Stats v1.27,see 1st post.

v1.27, Added RT_FunctionExist, RT_DebugF. Changed all returned Global vars to Local vars except for RT_SignalDAR (Sets default DAR for MeGUI).

New Funcs

RT_FunctionExist(string)
Given the name (string) of the Function that you want to test for existence, returns true if exists, else false.



RT_DebugF(string format,dat1,...,datn,string "name"="RT_DebugF:",int "TabSz"=4)
Sends a formatted string to DebugView Window. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the
text string that is sent to DebugView, uses C/CPP printf() style formatting.
Format: compulsory string controlling format and describing the datn type args that are expected.
datn: Variable number of data args of any type (excluding clip).
Name, Default "RT_DebugF:". Allows you to change the default name prepended to each line of text output to DebugView Window.
TabSz, Default 4 (1 ->32). TAB step setting used for Chr(9) tab ('\t') character.
To set either Name or TabSz, you must use the named form eg Name="NewName:" or TabSz=8 as Avisynth does not know where the data args
end.

printf Format spec here:- http://msdn.microsoft.com/en-us/library/56e442dc%28v=vs.71%29.aspx
NOTE, the only support for printing Bool variables is %s as string, ie prints "True" or "False".
Formatting supported %[flags] [width] [.precision] type
flags, one of "-,+,0, ,#"
width, integer, "*" supported (width supplied via dat arg).
Precision, integer, "*" supported (precision supplied via dat arg).
type,
"c,C,d,i,o,u,x,X", Integer type, c,C=character, d,i=signed, o,u,x,X=unsigned (o=octal, x=Hex).
"e,E,f,g,G", Floating point type
"s,S", String type (also Bool).

Formatting Insertion point is marked with '%' character in the format string (as in Avisynth String function), if you wish to use
a percent character within the output string, it should be inserted twice in the format string ie '%%' will produce a single '%'.
The data datn arg strings do not require a double '%' character.

A Backslash character '\' introduces escape sequences, to insert a backslash character itself, you must supply a double
backslash sequence ie '\\'.
Converts embedded escape character sequences (Case Significant):-
'\\' Converted to '\' Single Backslash
'\n' Converted to Chr(10) NewLine
'\r' [and Chr(13)] Converted to Chr(10) NewLine
'\t' [and Chr(9)] Converted to multiple SPACE's. Horizontal TAB (Tab positions relative to name + SPACE [if not ending in SPACE])
'\x', where x is ANY OTHER CHARACTER not included above, will be copied verbatim, ie '\x'.

Escape sequences are replaced only when occurring in the format string, if you need escapes in data string then use RT_String and
RT_Debug functions.

Example:
RT_DebugF("Hello there %s and %s.\nGoodbye %d.","Fred","Ted",2013)
would output same as:- RT_Debug("Hello there Fred and Ted." + Chr(10) + "Goodbye 2013.")

Forensic
18th October 2013, 05:18
RT_FunctionExist is awesome. Try/Catch was too generic and could not discern between a missing function or a failed function. Thank you.

StainlessS
18th October 2013, 09:04
Glad you like it Forensic, have to say though that it was a doddle to implement, at most 2 minutes.
(EDIT: Already implemented in Avisynth interface and available to plugin writers, so just needed supply name string and return result)

StainlessS
27th October 2013, 16:06
Following on from this OT post: http://forum.doom9.org/showthread.php?p=1650239#post1650239

I shall start to implement suggested RT_Array style funcs, shall try to post today as I am busy for next few days.
It is not much harder to implement fixed size strings, so long as the array type is fixed on allocation. Will also implement for bool.
Perhaps at some future point it could be implemented for BYTE sized int, ie binary Array.

EDIT: Shall flag it as Beta version, to give others time to review implementation .

martin53
27th October 2013, 17:48
StainlessS,
I look forward to use 1 dimensional arrays with clip length bounds mostly. For example, would be time saving to fill it with scene change information at script start, or similar frame related information that costs time to retrieve again and again.

Deshakers and I don't know what functions could then be written based on the data in the array instead as low pass filters for the difference between current and previous frame - and all the while spoiling the non linear concept that way.

You wrote that you are going to store the data in files. I assume the plugin will automatically create and destroy them, and to the possible extent, care that they are in the HD cache for fast access...

Gavino
27th October 2013, 18:13
I shall start to implement suggested RT_Array style funcs, shall try to post today as I am busy for next few days.
How would these compare with AviSynthLib?

StainlessS
28th October 2013, 04:55
How would these compare with AviSynthLib?

Dont know, have got that lib but cant recall if I've ever looked at it. Why not judge for yourself.

RT_stats v1.28 Beta, here: LINK REMOVED

New funcs

Added to v1.28 Beta

***
***
***

RT_IncrGlobal(string GlobalName,int "Init"=1)
Given the name of a Global Int variable, will increment that Global (ie add 1 to it) and return the result.
If Global int does not exist, will initialize it to the optional Init arg, default 1.
So if GlobalInt is already initialized to 1, then RT_IncrGlobal("GlobalInt") sets GlobalInt to 2
(equiv:- Global GlobalInt = GlobalInt + 1).
If GlobalName exists in local scope as a local variable, then it will set the same named Global Variable
to the value of the local variable + 1, local variables 'hide' similarly named Global variables, and a plugin
cannot tell the difference between local and global variables, so make sure you do not use local variables
of similar names to global ones.
Will throw an error if GlobalName exists but variable is not of type Int.


***
***
***

RT_ArrayAlloc(string FileName,int "Type"=1,int "Nels"=0,int "StringLenMax"=256)
Creates a file to hold Array elements of type Bool, Int, Float or String.
Filename, Array Filename, no default.
Type, int, default 1(0 -> 3). 0=Bool, 1=Int, 2 = Float, 3 = String.
Nels, default 0. Number of array elements, initialized to zeros.
StringLenMax, default 256(greater than zero). Fixed Maximum string length excluding nul term. Error if string length exceeds.
Only used for Type=3 (string).
Returns number of elements in array. All errors produce an error alert.
***
***
***

RT_ArrayGetType(string FileName)
Filename, Array Filename, no default.
Returns int, Type as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNels(string FileName)
Filename, Array Filename, no default.
Returns int, Nels as set by RT_ArrayAlloc, or current Nels if RT_ArrayAppend used to add vars to end of array.

***
***
***

RT_ArrayGetElSize(string FileName)
Filename, Array Filename, no default.
Returns int, element size, Type 0(bool)=1, 1(int)=4, 2(float)=4, 3(string)=StringLenMax as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNelMax(string FileName)
Filename, Array Filename, no default.
Returns int, maximum number of elements that could theoretically be stored in array, based on (maximum +ve integer - header size) / ElSize.

***
***
***

RT_ArrayGet(string FileName,int Nel)
Filename, Array Filename, no default.
Nel, int, zero relative. Valid range 0 -> RT_ArrayGetNels(FileName) - 1.
Returns Array(Nel) of variable Type as set in RT_ArrayAlloc.

***
***
***

RT_ArraySet(string FileName,int Nel,Var)
Filename, Array Filename, no default.
Nel, int, zero relative. Valid range 0 -> RT_ArrayGetNels(FileName) - 1.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in array.

***
***
***

RT_ArrayAppend(string FileName,Var)
Adds a variable to end of array and increments the Nel count.
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in array.


RT_Array_Test.Avs

/*
RT_ArrayAlloc(string FileName,int "Type"=1,int "Nels"=0,int "StringLenMax"=256)
RT_ArrayGetType(string FileName)
RT_ArrayGetNels(string FileName)
RT_ArrayGetElSize(string FileName)
RT_ArrayGetNelMax(string FileName)
RT_ArrayGet(string FileName,int nel)
RT_ArraySet(string FileName,int nel,var)
RT_ArrayAppend(string FileName,var)
*/

ARRAY="TestArray"
TYPE = 3 # 0=Bool,1=Int,2=Float,3=String
NELS = 128 # Inital Number of Array elements (init'ed to zero's)
STRINGLENMAX = 16 # Excluding Nul Term

ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ALPHA=ALPHA+ALPHA # Len 260

GScript("""
RT_DebugF("")
RT_ArrayAlloc(ARRAY,Type=TYPE,Nels=NELS,stringlenmax=STRINGLENMAX)
RT_DebugF("Type = %d",RT_ArrayGetType(ARRAY))
RT_DebugF("Nels = %d",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
RT_DebugF("\nChecking Init")
for(i=0,NELS-1) {
if(TYPE==0) { # Bool
if(RT_ArrayGet(ARRAY,i) != False) {
RT_DebugF("BOOL(%d) Init != False",i)
}
} Else if(TYPE==1) { # Int
if(RT_ArrayGet(ARRAY,i) != 0) {
RT_DebugF("INT(%d) Init != 0",i)
}
} Else if(TYPE==2) { # Float
if(RT_ArrayGet(ARRAY,i) != 0) {
RT_DebugF("FLOAT(%d) Init != 0.0",i)
}
} Else if(TYPE==3) { # String
if(RT_ArrayGet(ARRAY,i) != "") {
RT_DebugF("STRING(%d) Init != %c%c",i,34,34)
}
}
}
Try {RT_ArrayGet(ARRAY,NELS) RT_DebugF("Init END Check FAILED")} catch (err) {RT_DebugF("Init END Check Passed")}
RT_DebugF("Checking Set/Get")
for(i=0,NELS-1) {
if(TYPE==0) {vs = RT_BitTST(i,0) }
Else if(TYPE==1) {vs = i }
Else if(TYPE==2) {vs = Float(i) }
Else if(TYPE==3) {vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) }
RT_ArraySet(ARRAY,i,vs)
vg=RT_ArrayGet(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
RT_DebugF("Checking Append/Get")
for(i=NELS,NELS*2-1) {
if(TYPE==0) {vs = RT_BitTST(i,0) }
Else if(TYPE==1) {vs = i }
Else if(TYPE==2) {vs = Float(i) }
Else if(TYPE==3) {vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) }
RT_ArrayAppend(ARRAY,vs)
vg=RT_ArrayGet(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
if(RT_ArrayGetNels(ARRAY) != NELS * 2) {
RT_DebugF("Final Check ERROR, RT_ArrayGetNels != NELS *2 (is %d)",RT_ArrayGetNels(ARRAY))
}
RT_DebugF("ALL Checks Done\n")
RT_DebugF("Type = %d",RT_ArrayGetType(ARRAY))
RT_DebugF("Nels = %d (Should have doubled)",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
""")
return colorbars()


avs output to debugview


00000005 1.97394645 RT_DebugF:
00000006 1.98214269 RT_DebugF: Type = 3
00000007 1.98232949 RT_DebugF: Nels = 128
00000008 1.98250961 RT_DebugF: ElSize = 16
00000009 1.98278558 RT_DebugF: NelMax = 134217711 ($7FFFFEF)
00000010 1.98286307 RT_DebugF:
00000011 1.98288894 RT_DebugF: Checking Init
00000012 1.99807060 RT_DebugF: Init END Check Passed
00000013 1.99814630 RT_DebugF: Checking Set/Get
00000014 2.23899317 RT_DebugF: Checking Append/Get
00000015 2.56599188 RT_DebugF: ALL Checks Done
00000016 2.56603646 RT_DebugF:
00000017 2.56626225 RT_DebugF: Type = 3
00000018 2.56645536 RT_DebugF: Nels = 256 (Should have doubled)
00000019 2.56664443 RT_DebugF: ElSize = 16
00000020 2.56693482 RT_DebugF: NelMax = 134217711 ($7FFFFEF)


by Martin53, You wrote that you are going to store the data in files. I assume the plugin will automatically create and destroy them, and to the possible extent, care that they are in the HD cache for fast access...

Will create array, but NOT destroy, you might want to use array again later. Can use RT_FileDelete. Have done nothing to inhibit cache.
Gotta try and get some sleep now.

EDIT: With a array of type string and StringLenMax set sufficiently high, could create a database of avs scripts (or script filenames)
to eg load required plugins and avoid much typing/copying. Just a daft idea. :helpful:

martin53
29th October 2013, 08:07
Thank you for the work you did!
I would like to point out some details that I see.
- When scripts are published, the fixed filename, probably including path, might be an obstacle. I made the observation that depending on opening a script in AvsPmod, VDub via file/open or VDub via contextmenu "open with" or via drag & drop over the app window, the current path is sometimes the script path, sometimes the executable path. Classic file IO allowed a file to have a number, or better, an alias; and only the open command needs the file name. Otherwise many lines need to be adapted, and readability is bad.
- I often have several scripts open at the same time. So I'd need to implement a mechanism with an 'exist' loop to find the next free filename, and use that. Only starting from v2.60, AviSynth provides predefined variables for script path and name, and depending on method how script is opened, these variables are not set properly - see old thread (http://forum.doom9.org/showthread.php?p=1258062#post1258062) where we discussed all that stuff.
- If the script crashes, no cleanup funcs (RT_FileDelete()) on script level can be called in most cases (can be done with try/catch, but not every script is enclosed in try/catch etc)

So I'd like to propose these changes:
- RT_ArrayAlloc() allows filename to be empty, will then use %Temp%\UniqueFile itself, maybe return this name instead of Nels
- RT_ArrayAlloc() allows an additional string for the 'handle name' or 'variable name' of the array
- other functions then work with the latter instead of the file name: more naming freedom, better readability
- at least if RT_ArrayAlloc() was called with an empty file name, file is automatically deleted in plugin destructor. Alternatively an additional bool parameter to control this.

Gavino
29th October 2013, 09:40
Classic file IO allowed a file to have a number, or better, an alias; and only the open command needs the file name. Otherwise many lines need to be adapted, and readability is bad.
That's easily solved by assigning the name to a variable and using that instead of a literal in the function calls. Then only one line (the assignment) needs to be changed. Indeed, StainlessS's example uses this technique.

martin53
29th October 2013, 20:03
OK, that's true.
My objection that I'd prefer automatic filename handling is still valid.

@StainlessS: Is the filename parameter able to expand environment strings like %temp%, or do you suggest to use e.g. the GetSystemEnv plugin for that?

martin53
29th October 2013, 21:32
StainlessS,
would like to ask you for two more extensions of RT_Stats.
Overall objective: Plugin checks for published scripts. Users frequently try without installing the prerequisites, are disappointed and need forum help. A better platform to check the installed environment from the script would be helpful.

First extension: RT_plugindir2_5().
Return value: String with registry key HKLM\SOFTWARE\AviSynth\plugindir2_5.
Specific objective: get path name of installed plugins (assumed user does not include them via include commands from somewhere else, but then user is also able to comment out assertion lines)

Second extension: adaption of all 4 GetSystemEnv plugin (http://forum.doom9.org/showthread.php?t=142485) functions, but specifically RT_GetSystemEnv() and RT_GetFileInfo().
Specific objective: enable user to read/write files in %TEMP% directory rather than C:\, WorkingDir or ScriptDir (latter might be write protected, first is not a good place to litter, no other path does exist on all OS installations), and get modification date of plugin dlls. Also, get absolute path of %windir%\system32\avisynth.dll.
RT_GetFileInfo() must return the date and time string as "YYYY-MM-DD hh:mm:ss", not locale-specific, see below

A published script could then assert the existence not only of certain plugins, as withtry { BlankClip.RT_Stats } catch(err) { assert(false, "Please get RT_Stats plugin for this script") }
assert(RT_FunctionExist("mt_lut"), "Please get mt_masktools")
...
but also the minimum version - without requiring that the plugins themselves expose version information - with assert((RT_GetSystemEnv("windir")+"\system32\avisynth.dll").RT_GetFileInfo("ModificationTime")>"2013-01-13", "Please get AviSynth v2.6a4 or higher")
assert(RT_plugindir2_5.RT_GetFileInfo("ModificationTime")>"2013-10-16", "RT_Stats is too old. Please get v1.28")

RT_Stats has really become a swiss knife, and the advantage of including the functions in RT_Stats is that only one assertion for the existence of RT_Stats itself must be made without the help of it.

StainlessS
29th October 2013, 22:57
EDIT: @M53,
Not terribly sensible at the moment, did not like almost any of your previous ideas.
but always willing to listen, and when I'm again alive/awake/not drunk/ shall review again.

StainlessS
1st November 2013, 15:49
Sorry, M53, not ignoring you, will get around to answering. Please be patient.

StainlessS
2nd November 2013, 23:07
New Version RT_Stats v1.28Beta2 here:- LINK REMOVED



Added to v1.28 Beta-2


RT_IncrGlobal(string GlobalName,int "Init"=1)
Given the name of a Global Int variable, will increment that Global (ie add 1 to it) and return the result.
If Global int does not exist, will initialize it to the optional Init arg, default 1.
So if GlobalInt is already initialized to 1, then RT_IncrGlobal("GlobalInt") sets GlobalInt to 2
(equiv:- Global GlobalInt = GlobalInt + 1).
If GlobalName exists in local scope as a local variable, then it will set the same named Global Variable
to the value of the local variable + 1, local variables 'hide' similarly named Global variables, and a plugin
cannot tell the difference between local and global variables, so make sure you do not use local variables
of similar names to global ones.
Will throw an error if GlobalName exists but variable is not of type Int.

***
***
***

*****************************************************
********** RT_ARRAY FUNCTIONS ***********
*****************************************************

The RT_ArrayXXXX type functions are primitives intended to be lightweight. Added to v1.28Beta2 are 16 Attribute int's for
whatever purpose the script writer desires, eg dimensions for multi-dimension arrays (multi to single dimension handled by user script)
or some kind of bit flags. It could also be possible in script to create script functions to eg create a dictionary or database using
separate ARRAY's together, perhaps using a MASTER ARRAY to hold filenames of the subordinate arrays, and in the Attributes, the
subordinate array variable type. Perhaps the first subordinate array could hold the name of a plugin and the 2nd the full file path on
YOUR system (or a path relative to a user_plugin_dir on YOUR system). I am waiting for YOU to amaze me with your creativity.

***
***
***

RT_ArrayAlloc(string FileName,int "Type"=1,int "Nels"=0,int "StringLenMax"=256)
Creates a file to hold Array elements of type Bool, Int, Float, String, or BIN.
BIN is a BYTE (8 bit) sized Int where only lowest 8 bits of Int are stored in array as an unsigned 8 bit int, upper 24 bits ignored.
Filename, Array Filename, no default.
Type, int, default 1(0 -> 4). 0=Bool, 1=Int, 2 = Float, 3 = String, 4 = BIN.
Nels, default 0. Number of array elements, initialized to zeros (Bool=False,Float=0.0,String="").
StringLenMax, default 256(greater than zero). Fixed Maximum string length excluding nul term. Error if string length exceeds.
Only used for Type=3 (string).
Returns number of elements in array. All RT_ArrayXXXX() errors produce an error alert.

***
***
***

RT_ArrayGetType(string FileName)
Filename, Array Filename, no default.
Returns int, Type as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNels(string FileName)
Filename, Array Filename, no default.
Returns int, Nels as set by RT_ArrayAlloc, or current Nels if RT_ArrayAppend used to add vars to end of array.

***
***
***

RT_ArrayGetElSize(string FileName)
Filename, Array Filename, no default.
Returns int, element size, Type 0(bool)=1, 1(int)=4, 2(float)=4, 3(string)=StringLenMax, 4(BIN)=1, as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNelMax(string FileName)
Filename, Array Filename, no default.
Returns int, maximum number of elements that could theoretically be stored in array, based on (maximum +ve integer - header size) / ElSize.

***
***
***

RT_ArrayGet(string FileName,int Nel)
Filename, Array Filename, no default.
Nel, int, zero relative. Valid range 0 -> RT_ArrayGetNels(FileName) - 1.
Returns Array(Nel) of variable Type as set in RT_ArrayAlloc.
Type BIN returns an Int range 0 -> 255.

***
***
***

RT_ArraySet(string FileName,int Nel,Var)
Filename, Array Filename, no default.
Nel, int, zero relative. Valid range 0 -> RT_ArrayGetNels(FileName) - 1.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in array.

***
***
***

RT_ArrayAppend(string FileName,Var)
Adds a variable to end of array and increments the Nel count.
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in array.

***
***
***

RT_ArrayGetAttrib(string FileName,int ix)
There are 16 avalable int attributes in the Array file header, that can be used for whatever purpose you like,
perhaps array dimensions where user script handles multiple dimension array.
RT_ArrayAlloc() initializes all Attributes to 0.
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Returns the value of the user set attribute (or 0 if not yet set).

***
***
***

RT_ArraySetAttrib(string FileName,int ix,int value)
There are 16 avalable int attributes in the Array file header, that can be used for whatever purpose you like,
perhaps array dimensions where user script handles multiple dimension array.
RT_ArrayAlloc() initializes all Attributes to 0.
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Value, int, The value that Attrib(ix) will be set to.
Returns value.


*****************************************************
********** OTHER FUNCTIONS ***********
*****************************************************

RT_Version()
Returns the Float version number of RT_Stats, but slightly modified for beta versions.
A non beta version would return a number like 1.28, with two decimal digits of precision.
A version of v1.28Beta2 shown by RT_Stats() on frame, will return 1.2792 rather than 1.28.
9 in the 1/1000's position signifies the beta version in the 1/10000's column.
This allows direct comparison of version numbers including Beta versions

***
***
***

RT_VersionString()
Return RT_Stats version as a string eg "1.28Beta2".

***
***
***

RT_VersionDll()
Return RT_Stats(26).dll version as a Float eg 2.6 for Avistynth v2.6, or 2.5 for Avisynth 2.5.

***
***
***

RT_ScriptDir()
Returns String, Path to Script Directory. Same as ScriptDir in Avisynth v2.6.
Returns "", if cannot find ScriptDir.

***
***
***

RT_ScriptFile()
Returns String, filename of Script without path. Same as ScriptFile in Avisynth v2.6.
Returns "", if cannot find ScriptFile.


***
***
***

RT_ScriptName()
Returns String, filename of Script including path. Same as ScriptName in Avisynth v2.6.
Returns "", if cannot find ScriptName.


***
***
***

RT_PluginDir()
Returns String, path to Avisynth plugins directory.
Returns "", if plugin dir not found.


***
***
***

RT_InternalFunctions()
Returns String, SPACE separated list of internal filter and function names.
Returns "", if cannot find InternalFunctions.
If you like a good read try this:-
S=RT_StrReplace(RT_InternalFunctions," ",Chr(10))
ColorBars.ScriptClip("""RT_Subtitle("%s",S,align=5,y=height+100-current_frame,expx=true,expy=true)""").killaudio

***
***
***

RT_PluginFunctions()
Returns String, SPACE separated list of external filter and function names.
Returns "", if cannot find PluginFunctions.
If you like a good read try this:-
S=RT_StrReplace(RT_PluginFunctions," ",Chr(10))
ColorBars.ScriptClip("""RT_Subtitle("%s",S,align=5,y=height+100-current_frame,expx=true,expy=true)""").killaudio

***
***
***

RT_PluginParam(String FunctionName)
FunctionName, String, name of Avisynth built-in or Plugin filter or function name.
Returns "", if FunctionName Parameter string not found.
Returns String, the Avisynth CPP Interface style argument specifier string used by Avisynth to determine argument types and optional names.
Optional arguments have square brackets surrounding their name as in [name] and are followed by a type specifier character that gives
the type. Unnamed arguments are not optional. eg "cc[arg1]b[arg2]i" would be two compulsory unnamed clip args, followed by optional
'arg1' of type bool and optional 'arg2' of type int.
# Argument type specifier strings.
c - Video Clip
i - Integer number
f - Float number
s - String
b - boolean
. - Any type (dot)
# Array Specifiers
i* - Integer Array, zero or more
i+ - Integer Array, one or more
.* - Any type Array, zero or more
.+ - Any type Array, one or more
# Etc
To show params:-
colorbars().Killaudio()
S=RT_PluginParam("RT_YStats")
S=RT_StrReplace(S,"[",Chr(10)+"[")
RT_Subtitle(s)

***
***
***




- When scripts are published, the fixed filename, probably including path, might be an obstacle. I made the observation that depending on opening a script in AvsPmod, VDub via file/open or VDub via contextmenu "open with" or via drag & drop over the app window, the current path is sometimes the script path, sometimes the executable path. Classic file IO allowed a file to have a number, or better, an alias; and only the open command needs the file name. Otherwise many lines need to be adapted, and readability is bad.
- I often have several scripts open at the same time. So I'd need to implement a mechanism with an 'exist' loop to find the next free filename, and use that. Only starting from v2.60, AviSynth provides predefined variables for script path and name, and depending on method how script is opened, these variables are not set properly - see old thread (http://forum.doom9.org/showthread.php?p=1258062#post1258062) where we discussed all that stuff.
- If the script crashes, no cleanup funcs (RT_FileDelete()) on script level can be called in most cases (can be done with try/catch, but not every script is enclosed in try/catch etc)

So I'd like to propose these changes:
- RT_ArrayAlloc() allows filename to be empty, will then use %Temp%\UniqueFile itself, maybe return this name instead of Nels
- RT_ArrayAlloc() allows an additional string for the 'handle name' or 'variable name' of the array
- other functions then work with the latter instead of the file name: more naming freedom, better readability
- at least if RT_ArrayAlloc() was called with an empty file name, file is automatically deleted in plugin destructor. Alternatively an additional bool parameter to control this.

Dont really like any of the above, sorry.

It is intended that the array function suite be as lightweight as possible (primitives), and that a user can implement eg multi-dimensional
arrays via script functions. Have now implemented 16 int sized array attributes, could be used to store dimensions, or eg bitflags for
whatever usage.
Having to mess with filenames should be in the hands of the client script, perhaps I could implement a unique filename generator or whatever
but best left out of the array routines and auto deletion is a no-go, runtime filters have no destructor.
The ARRAY file is opened and closed on each access, so the name is needed, I would not entertain the idea of using any kind of file handle
and expecting the script user to deal properly with files, also although it may not be impossible to tie the invididual routines together
to use a single memory area, I would not like to try to implement this and have no idea what additional problems (if any) might arise in
eg multi-threaded versions of avisynth.
Having to use a variable holding a handle, is not really any different to using a variable holding a filename.
Perhaps a function to delete filenames on Avisynth exit could be written, but Ive never written an onexit type func and may have additional
complications if more than a single file were required to be deleted, myself I would prefer if half completed files were left in-situ
(after crash), might help in diagnositcs on cause, and dont really like a file being created 'somewhere on some hard drive'.


@StainlessS: Is the filename parameter able to expand environment strings like %temp%, or do you suggest to use e.g. the GetSystemEnv plugin for that?

I was curious about that myself so I tried it. Tried ARRAY="%TEMP%\TestArray" which failed.


Addition Requests,
RT_PluginDir() DONE
RT_GetSystemEnv() OK, Coming
RT_GetFileInfo() OK, Coming

Written some time later:-
Am thinking about making primitives multi-dimensional, either 2 or 3 max dimensions, if so, then args to array funcs will change.

StainlessS
2nd November 2013, 23:13
See previous post for new version RT_Stats v1.28Beta2

RT_Test_Array.Avs

# RT_Test_Array.Avs

/*
RT_ArrayAlloc(string FileName,int "Type"=1,int "Nels"=0,int "StringLenMax"=256)
RT_ArrayGetType(string FileName)
RT_ArrayGetNels(string FileName)
RT_ArrayGetElSize(string FileName)
RT_ArrayGetNelMax(string FileName)
RT_ArrayGet(string FileName,int nel)
RT_ArraySet(string FileName,int nel,var)
RT_ArrayAppend(string FileName,var)
RT_ArrayGetAttrib(string FileName,int ix)
RT_ArraySetAttrib(string FileName,int ix,int value)
*/

ARRAY="TestArray.ARR" # ARRAY name
START_TYPE = 0 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int)
END_TYPE = 4 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int) ## >= START_TYPE ##
NELS = 100000 # Inital Number of Array elements (init'ed to zero's) [Will be doubled by Append/Get]
STRINGLENMAX = 64 # Excluding Nul Term.
# Take care with NELS and STRINGLENMAX when processing Type=String.
# Approx string usage greater than (NELS * (STRINGLENMAX+1) * 6)
# String memory not released till Avisynth closure, no dead string garbage collection by Avisynth.
DELETE = True # True = Delete ARRAY file when done

ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ALPHA=ALPHA+ALPHA # Len 260
ALPHA=(STRINGLENMAX<STRLEN(ALPHA)) ? LeftStr(ALPHA,STRINGLENMAX) : ALPHA # cut down string manips and usage

TYPENAMES=RT_String("BOOL\nINT\nFLOAT\nSTRING\nBIN\n")

GScript("""
RT_DebugF("RT_Test_Array.avs")
TOTAL_START=RT_Timer()
RT_DebugF("")
For(TYPE=START_TYPE,END_TYPE) {
RT_DebugF("==============================")
TYPE_START=RT_Timer()
RT_ArrayAlloc(ARRAY,Type=TYPE,Nels=NELS,stringlenmax=STRINGLENMAX)
STOP=RT_Timer()
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Nels = %d",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
RT_DebugF("Alloc Time = %.3f secs (Per element %f microsecs)",STOP-TYPE_START,1000000.0*(STOP-TYPE_START)/NELS)
RT_DebugF("\nCheck Init")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i)) {RT_DebugF("BOOL(%d) Init != False",i)}}
} Else if(TYPE==1) { # Int
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0) {RT_DebugF("INT(%d) Init != 0",i)}}
} Else if(TYPE==2) { # Float
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0) {RT_DebugF("FLOAT(%d) Init != 0.0",i)}}
} Else if(TYPE==3) { # String
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != ""){RT_DebugF("STRING(%d) Init != %c%c",i,34,34)}}
} Else if(TYPE==4) { # BIN
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0) {RT_DebugF("BIN(%d) Init != 0",i)}}
}
Try {RT_ArrayGet(ARRAY,NELS) RT_DebugF("Init END Check FAILED")} catch (err) {RT_DebugF("Init END Check Passed")}
STOP=RT_Timer()
RT_DebugF("Check Init Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Attributes Set/Get")
START=RT_Timer()
for(i=0,15) {
vs=i*1000
RT_ArraySetAttrib(ARRAY,i,vs)
vg = RT_ArrayGetAttrib(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d SetAttrib/GetAttrib Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
STOP=RT_Timer()
RT_DebugF("Check Attributes Set/Get = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Set only Time Test on %d Nels",NELS)
vs=Select(TYPE,True,42,42.0,RightStr(ALPHA + "_" + String(42),STRINGLENMAX) ,42)
START=RT_Timer()
for(i=0,NELS-1) {
RT_ArraySet(ARRAY,i,vs)
}
STOP=RT_Timer()
RT_DebugF("Check Set Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Get only Time Test on %d Nels",NELS)
START=RT_Timer()
for(i=0,NELS-1) {RT_ArrayGet(ARRAY,i)}
STOP=RT_Timer()
RT_DebugF("Check Get Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Set/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,NELS-1) {
vs = RT_BitTST(i,0) RT_ArraySet(ARRAY,i,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==1) { # Int
for(i=0,NELS-1) {
vs = i RT_ArraySet(ARRAY,i,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==2) { # Float
for(i=0,NELS-1) {
vs = Float(i) RT_ArraySet(ARRAY,i,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==3) { # String
for(i=0,NELS-1) {
vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) RT_ArraySet(ARRAY,i,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==4) { # BIN
for(i=0,NELS-1) {
vs = RT_BitAnd(i,$FF) RT_ArraySet(ARRAY,i,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Compare Set/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Append/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=NELS,NELS*2-1) {
vs = RT_BitTST(i,0) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==1) { # Int
for(i=NELS,NELS*2-1) {
vs = i RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==2) { # Float
for(i=NELS,NELS*2-1) {
vs = Float(i) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==3) { # String
for(i=NELS,NELS*2-1) {
vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==4) { # BIN
for(i=NELS,NELS*2-1) {
vs = RT_BitAnd(i,$FF) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
}
if(RT_ArrayGetNels(ARRAY) != NELS * 2) {
RT_DebugF("Final Check ERROR, RT_ArrayGetNels != NELS *2 (is %d)",RT_ArrayGetNels(ARRAY))
}
STOP=RT_Timer()
RT_DebugF("Check Compare Append/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("ALL Checks Done\n")
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Nels = %d (Should have doubled)",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
STOP=RT_Timer()
RT_DebugF("Total Time Type=%d (%s) = %.3f secs",Type,RT_TxtGetLine(TYPENAMES,Type),STOP-TYPE_START)
}
(DELETE) ? RT_FileDelete(ARRAY) : NOP
TOTAL_STOP=RT_Timer()
RT_DebugF("SCRIPT TOTAL TIME = %.3f secs",TOTAL_STOP-TOTAL_START)
""")
return colorbars()


Results Following post (exceeds D9 16kb limit)

StainlessS
2nd November 2013, 23:13
See previous two posts

Results from debugview

00000001 0.00000000 RT_DebugF: RT_Test_Array.avs
00000002 0.00013451 RT_DebugF:
00000003 0.00022344 RT_DebugF: ==============================
00000004 0.00160964 RT_DebugF: Type = 0 (BOOL)
00000005 0.00178056 RT_DebugF: Nels = 100000
00000006 0.00194980 RT_DebugF: ElSize = 1
00000007 0.00219927 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000008 0.00229950 RT_DebugF: Alloc Time = 0.015 secs (Per element 0.150000 microsecs)
00000009 0.00238137 RT_DebugF:
00000010 0.00240546 RT_DebugF: Check Init
00000011 8.29076195 RT_DebugF: Init END Check Passed
00000012 8.29092121 RT_DebugF: Check Init Time = 8.281 secs (Per element 82.809990 microsecs)
00000013 8.29100418 RT_DebugF: Check Attributes Set/Get
00000014 8.29455185 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000015 8.29464054 RT_DebugF: Check Set only Time Test on 100000 Nels
00000016 20.87353134 RT_DebugF: Check Set Only Time = 12.579 secs (Per element 125.790001 microsecs)
00000017 20.87361526 RT_DebugF: Check Get only Time Test on 100000 Nels
00000018 29.33578873 RT_DebugF: Check Get Only Time = 8.468 secs (Per element 84.680000 microsecs)
00000019 29.33587074 RT_DebugF: Check Compare Set/Get
00000020 57.12252045 RT_DebugF: Check Compare Set/Get Time = 27.782 secs (Per element 277.820007 microsecs) [Including Data generation]
00000021 57.12260437 RT_DebugF: Check Compare Append/Get
00000022 86.21274567 RT_DebugF: Check Compare Append/Get Time = 29.093 secs (Per element 290.930023 microsecs) [Including Data generation]
00000023 86.21282959 RT_DebugF: ALL Checks Done
00000024 86.21285248 RT_DebugF:
00000025 86.21306610 RT_DebugF: Type = 0 (BOOL)
00000026 86.21323395 RT_DebugF: Nels = 200000 (Should have doubled)
00000027 86.21340179 RT_DebugF: ElSize = 1
00000028 86.21364594 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000029 86.21384430 RT_DebugF: Total Time Type=0 (BOOL) = 86.218 secs
00000030 86.21392822 RT_DebugF: ==============================
00000031 86.21581268 RT_DebugF: Type = 1 (INT)
00000032 86.21598053 RT_DebugF: Nels = 100000
00000033 86.21614838 RT_DebugF: ElSize = 4
00000034 86.21640015 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000035 86.21649933 RT_DebugF: Alloc Time = 0.016 secs (Per element 0.159988 microsecs)
00000036 86.21658325 RT_DebugF:
00000037 86.21660614 RT_DebugF: Check Init
00000038 94.72898102 RT_DebugF: Init END Check Passed
00000039 94.72914124 RT_DebugF: Check Init Time = 8.500 secs (Per element 85.000000 microsecs)
00000040 94.72921753 RT_DebugF: Check Attributes Set/Get
00000041 94.73278809 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.159988 microsecs)
00000042 94.73288727 RT_DebugF: Check Set only Time Test on 100000 Nels
00000043 107.19555664 RT_DebugF: Check Set Only Time = 12.453 secs (Per element 124.530029 microsecs)
00000044 107.19564056 RT_DebugF: Check Get only Time Test on 100000 Nels
00000045 115.66921234 RT_DebugF: Check Get Only Time = 8.484 secs (Per element 84.839943 microsecs)
00000046 115.66929626 RT_DebugF: Check Compare Set/Get
00000047 137.12696838 RT_DebugF: Check Compare Set/Get Time = 21.453 secs (Per element 214.530014 microsecs) [Including Data generation]
00000048 137.12704468 RT_DebugF: Check Compare Append/Get
00000049 159.96316528 RT_DebugF: Check Compare Append/Get Time = 22.844 secs (Per element 228.439941 microsecs) [Including Data generation]
00000050 159.96325684 RT_DebugF: ALL Checks Done
00000051 159.96327209 RT_DebugF:
00000052 159.96348572 RT_DebugF: Type = 1 (INT)
00000053 159.96365356 RT_DebugF: Nels = 200000 (Should have doubled)
00000054 159.96382141 RT_DebugF: ElSize = 4
00000055 159.96406555 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000056 159.96424866 RT_DebugF: Total Time Type=1 (INT) = 73.766 secs
00000057 159.96434021 RT_DebugF: ==============================
00000058 159.96620178 RT_DebugF: Type = 2 (FLOAT)
00000059 159.96636963 RT_DebugF: Nels = 100000
00000060 159.96653748 RT_DebugF: ElSize = 4
00000061 159.96679688 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000062 159.96688843 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000063 159.96696472 RT_DebugF:
00000064 159.96701050 RT_DebugF: Check Init
00000065 168.78349304 RT_DebugF: Init END Check Passed
00000066 168.78366089 RT_DebugF: Check Init Time = 8.812 secs (Per element 88.120117 microsecs)
00000067 168.78373718 RT_DebugF: Check Attributes Set/Get
00000068 168.78729248 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000069 168.78738403 RT_DebugF: Check Set only Time Test on 100000 Nels
00000070 181.40660095 RT_DebugF: Check Set Only Time = 12.625 secs (Per element 126.250000 microsecs)
00000071 181.40667725 RT_DebugF: Check Get only Time Test on 100000 Nels
00000072 189.87194824 RT_DebugF: Check Get Only Time = 8.469 secs (Per element 84.689941 microsecs)
00000073 189.87202454 RT_DebugF: Check Compare Set/Get
00000074 237.55381775 RT_DebugF: Check Compare Set/Get Time = 47.688 secs (Per element 476.880035 microsecs) [Including Data generation]
00000075 237.55390930 RT_DebugF: Check Compare Append/Get
00000076 286.65341187 RT_DebugF: Check Compare Append/Get Time = 49.093 secs (Per element 490.929871 microsecs) [Including Data generation]
00000077 286.65350342 RT_DebugF: ALL Checks Done
00000078 286.65350342 RT_DebugF:
00000079 286.65371704 RT_DebugF: Type = 2 (FLOAT)
00000080 286.65390015 RT_DebugF: Nels = 200000 (Should have doubled)
00000081 286.65405273 RT_DebugF: ElSize = 4
00000082 286.65429688 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000083 286.65451050 RT_DebugF: Total Time Type=2 (FLOAT) = 126.687 secs
00000084 286.65457153 RT_DebugF: ==============================
00000085 286.67214966 RT_DebugF: Type = 3 (STRING)
00000086 286.67233276 RT_DebugF: Nels = 100000
00000087 286.67248535 RT_DebugF: ElSize = 64
00000088 286.67276001 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000089 286.67288208 RT_DebugF: Alloc Time = 0.016 secs (Per element 0.160217 microsecs)
00000090 286.67297363 RT_DebugF:
00000091 286.67297363 RT_DebugF: Check Init
00000092 295.52035522 RT_DebugF: Init END Check Passed
00000093 295.52050781 RT_DebugF: Check Init Time = 8.859 secs (Per element 88.589783 microsecs)
00000094 295.52059937 RT_DebugF: Check Attributes Set/Get
00000095 295.52416992 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000096 295.52426147 RT_DebugF: Check Set only Time Test on 100000 Nels
00000097 308.34729004 RT_DebugF: Check Set Only Time = 12.829 secs (Per element 128.290100 microsecs)
00000098 308.34735107 RT_DebugF: Check Get only Time Test on 100000 Nels
00000099 316.90744019 RT_DebugF: Check Get Only Time = 8.546 secs (Per element 85.459900 microsecs)
00000100 316.90750122 RT_DebugF: Check Compare Set/Get
00000101 365.86749268 RT_DebugF: Check Compare Set/Get Time = 48.969 secs (Per element 489.690247 microsecs) [Including Data generation]
00000102 365.86758423 RT_DebugF: Check Compare Append/Get
00000103 416.47927856 RT_DebugF: Check Compare Append/Get Time = 50.610 secs (Per element 506.099854 microsecs) [Including Data generation]
00000104 416.47937012 RT_DebugF: ALL Checks Done
00000105 416.47937012 RT_DebugF:
00000106 416.47958374 RT_DebugF: Type = 3 (STRING)
00000107 416.47976685 RT_DebugF: Nels = 200000 (Should have doubled)
00000108 416.47991943 RT_DebugF: ElSize = 64
00000109 416.48022461 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000110 416.48040771 RT_DebugF: Total Time Type=3 (STRING) = 129.829 secs
00000111 416.48049927 RT_DebugF: ==============================
00000112 416.48214722 RT_DebugF: Type = 4 (BIN)
00000113 416.48233032 RT_DebugF: Nels = 100000
00000114 416.48251343 RT_DebugF: ElSize = 1
00000115 416.48278809 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000116 416.48287964 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000117 416.48297119 RT_DebugF:
00000118 416.48300171 RT_DebugF: Check Init
00000119 425.30059814 RT_DebugF: Init END Check Passed
00000120 425.30075073 RT_DebugF: Check Init Time = 8.813 secs (Per element 88.129883 microsecs)
00000121 425.30084229 RT_DebugF: Check Attributes Set/Get
00000122 425.30444336 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000123 425.30453491 RT_DebugF: Check Set only Time Test on 100000 Nels
00000124 437.77297974 RT_DebugF: Check Set Only Time = 12.468 secs (Per element 124.679871 microsecs)
00000125 437.77307129 RT_DebugF: Check Get only Time Test on 100000 Nels
00000126 446.27523804 RT_DebugF: Check Get Only Time = 8.500 secs (Per element 85.000000 microsecs)
00000127 446.27529907 RT_DebugF: Check Compare Set/Get
00000128 474.72674561 RT_DebugF: Check Compare Set/Get Time = 28.454 secs (Per element 284.540100 microsecs) [Including Data generation]
00000129 474.72683716 RT_DebugF: Check Compare Append/Get
00000130 504.42544556 RT_DebugF: Check Compare Append/Get Time = 29.703 secs (Per element 297.030029 microsecs) [Including Data generation]
00000131 504.42553711 RT_DebugF: ALL Checks Done
00000132 504.42556763 RT_DebugF:
00000133 504.42578125 RT_DebugF: Type = 4 (BIN)
00000134 504.42593384 RT_DebugF: Nels = 200000 (Should have doubled)
00000135 504.42611694 RT_DebugF: ElSize = 1
00000136 504.42636108 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000137 504.42654419 RT_DebugF: Total Time Type=4 (BIN) = 87.953 secs
00000138 504.42694092 RT_DebugF: SCRIPT TOTAL TIME = 504.453 secs


Core Duo Dual Core 2.13GHz, 3GB DDR2, Half full non-system 320 GB SATA2

martin53
4th November 2013, 18:28
1) perhaps I could implement a unique filename generator or whatever but best left out of the array routines
2) auto deletion is a no-go, runtime filters have no destructor
3) Having to use a variable holding a handle, is not really any different to using a variable holding a filename

1) agree, maybe current system time with sufficient fine resolution is good for that (returned as >6 digit string? NTFS uses a 100ns time resolution afaik)
2) oops - agree, of course
3) agree, Gavino stated that too, variable name can be chosen as to indicate the array purpose

Also agree with the aspect that non-deleted file can help with debugging.

If %TEMP% can be resolved one day (outside of array routines is OK for that), then I can clean up that dir from time to time. During script writing, I have *lots* of crashes, :'(

martin53
4th November 2013, 19:39
Could not keep myself from trying these funny functions
global PATH = RT_ScriptDir + "\functions.txt"
RT_TxtWriteFile("======== Internal Functions ========", PATH, false)
RT_InternalFunctions.Write
RT_TxtWriteFile("======== Plugin Functions ========", PATH, true)
RT_PluginFunctions.Write
function Write(string s) {
i = s.FindStr(" ")
GScript(""" #"
while(i>0) {
if (i>1) {
fu = s.LeftStr(i-1)
if ((s.MidStr(i)).FindStr(" "+fu+" ") == 0 && (s.MidStr(i)).FindStr("_"+fu+" ") == 0) {
RT_TxtWriteFile(fu + " ( " + fu.RT_PluginParam + " )", PATH, true)
}
}
s = s.MidStr(i+1)
i = s.FindStr(" ")
}
""") #"
}
BlankClip().subtitle("See "+PATH) :D

StainlessS
5th November 2013, 03:27
Nice script m53.
Be aware that the latest string returning functions are bugged, I forgot that the internal CPP functions can release
these strings when eg loading new plugin and so could point at free'ed memory, have fixed but currently testing
RT_GetFileTime(), will release fixes later today.

EDIT:
If %TEMP% can be resolved

Done

StainlessS
6th November 2013, 04:28
New version RT_Stats v1.28Beta3 here:- LINK REMOVED
Bugged string returning functions fixed.

Additional:


RT_GetSystemEnv(String envname)
Returns a string from the System Environment with the env name of the string arg.
Returns "", if cannot find environment variable of given name.
eg, TEMP=RT_GetSystemEnv("TEMP") # to get TEMP folder path.
and eg
ComSpec=RT_GetSystemEnv("ComSpec") # might return "C:\WINDOWS\system32\cmd.exe"
To see the environment variables from command console, type 'set'.
http://en.wikipedia.org/wiki/Environment_variable

***
***
***

RT_GetFileTime(string filename,int item)
Returns string, one of three times associated with filename file.
Error if cannot access file. (debugview for error string).
Item, int, (0 -> 2). 0=Creation Time, 1=Last Write/Modified time 2=Last Accessed Time,
The return string is always of format "YYYY-MM-DD HH:MM:SS" and so can be used to
compare whether one file time is later than another using string comparison.
The time strings returned are in UTC (Coordinated Universal Time), not local time.


EDIT: Modified RT_Subtitle with additional Int "Esc"=1 arg:-

RT_Subtitle(clip source,string format,dat1,...,datn,int "align",int "x","y",bool "vcent"=false,bool "expx"=false,bool "expy"=false,int "esc"=1)
Standard filter function.
This function is a standard filter graph function, not a runtime/compile time function.
v2.5 plugin dll limited to v2.58 colorspaces.
Prints formatted text to clip frame using Avisynth Info.h source font (monospaced) and DDigit font renderer, faster than using
Subtitle system fonts. The unnamed 'format' string and optional unnamed 'dat' args are used to construct the text string that is
printed on frame, uses C/CPP printf() style formatting. The args 'align', 'x', and 'y', work in a similar fashion to
Avisynth Subtitle()
expx and expy control whether x and y are same as in SubTitle when eg y = -1 (vertical centered) or y=height (bottom aligned),
or as explicit coords when expy = true.

esc int, default 1. (0 -> 2). Escape code processing eg '\n' converted to Chr(10).
0 = No Escape code processing.
1 = Esc codes processed only in format string. (Default)
2 = Esc codes processed in both format and data strings.


Previously worked as for Esc=2.

Example to show colors:-

Colorbars.KillAudio
S=""" \a!\\a! DDIGIT_CC_HILITE
\a-\\a- DDIGIT_CC_DEFAULT
\a0\\a0 DDIGIT_CC_DARKGRAY
\a1\\a1 DDIGIT_CC_DODGERBLUE
\a2\\a2 DDIGIT_CC_ORANGERED
\a3\\a3 DDIGIT_CC_ORCHID
\a4\\a4 DDIGIT_CC_LIME
\a5\\a5 DDIGIT_CC_AQUAMARINE
\a6\\a6 DDIGIT_CC_YELLOW
\a7\\a7 DDIGIT_CC_WHITE
\a8\\a8 DDIGIT_CC_SILVER
\a9\\a9 DDIGIT_CC_CORNFLOWERBLUE
\aA\\aA DDIGIT_CC_ORANGE
\aB\\aB DDIGIT_CC_PLUM
\aC\\aC DDIGIT_CC_CHARTREUSE
\aD\\aD DDIGIT_CC_POWDERBLUE
\aE\\aE DDIGIT_CC_GOLD
\aF\\aF DDIGIT_CC_GAINSBORO
\aG\\aG DDIGIT_CC_Y_0
\aH\\aH DDIGIT_CC_Y_1
\aI\\aI DDIGIT_CC_Y_2
\aJ\\aJ DDIGIT_CC_Y_3
\aK\\aK DDIGIT_CC_Y_4
\aL\\aL DDIGIT_CC_Y_5
\aM\\aM DDIGIT_CC_Y_6
\aN\\aN DDIGIT_CC_Y_7
\aO\\aO DDIGIT_CC_Y_8
\aP\\aP DDIGIT_CC_Y_9
\aQ\\aQ DDIGIT_CC_Y_A
\aR\\aR DDIGIT_CC_Y_B
\aS\\aS DDIGIT_CC_Y_C
\aT\\aT DDIGIT_CC_Y_D
\aU\\aU DDIGIT_CC_Y_E
\aV\\aV DDIGIT_CC_Y_F"""
DELAY=100
ESC=2 # esc=2, ESC codes allowed in data strings
Scriptclip("""RT_Subtitle("%s",S,align=1,y=height+DELAY-current_frame,expy=true,esc=ESC)""")
return last

StainlessS
7th November 2013, 18:23
New version RT_Stats v1.28Beta4 here: LINK REMOVED
Added function


RT_LocalTimeString(Bool "file"=True)
Returns current local time as a string.
Where digits Y=Year, M=Month, D=Day, H=Hour, M=Minute, S=Second, m=millisecond.
When bool file==False, then string in format "YYYY-MM-DD HH:MM:SS.mmm"
When bool file==True (Default) string is in format "YYYYMMDD_HHMMSS_mmm"
Also when file==True, function first waits until the system tick count is incremented (about every 10ms)
before inquiring system time. This is to prevent 2 consecutive calls returning the same time string.
Perhaps useful for temporary filename generation.

martin53
8th November 2013, 08:20
Highly appreciate that! Will be unable to use in example until end of next week, but then will implement the new features in one of my RTE scripts, giving multi instance local var scope, true non linear access over frame groups. Wow!

StainlessS
10th November 2013, 00:25
Post #1 of 7

New Version RT_Stats v1.28Beta5, Here:- http://www.mediafire.com/download/4vk8jvkfo9qq2wu/RT_Stats_25%2626_dll_v1.28Beta5_20131109.zip

Changed:

RT_GetFileTime(string filename,int item)
Returns string, one of three times associated with filename file.
Error if cannot access file. (debugview for error string).
Item, int, (0 -> 2). 0=Creation Time, 1=Last Write/Modified Time 2=Last Accessed Time,
The return string is always of format "YYYY-MM-DD HH:MM:SS.mmm" and so can be used to
compare whether one file time is later than another using string comparison.
The time strings returned are in UTC (Coordinated Universal Time), not local time.
v1.28Beta5, added milliseconds to string.


RT_ArrayXXXX Modified for multi-dimensional arrays of 1, 2 and 3 dimensions.


*****************************************************
********** RT_ARRAY FUNCTIONS ***********
*****************************************************

RT_ArrayAlloc(string FileName,int "Type"=1,int "Dim1"=0,int "Dim2"=0,int "Dim3"=0,int "StringLenMax"=256)
Creates a file to hold Array elements of type Bool, Int, Float, String, or BIN.
BIN is a BYTE (8 bit) sized Int where only lowest 8 bits of Int are stored in array as an unsigned 8 bit int, upper 24 bits ignored.
Filename, Array Filename, no default.
Type, int, default 1(0 -> 4). 0=Bool, 1=Int, 2 = Float, 3 = String, 4 = BIN.
Dim1, Dim2, Dim3, all default 0. Number of array elements per dimension (max 3 dimensions),
initialized to zeros (Bool=False,Float=0.0,String="").
With all defaults of 0, would be single dimension array with zero allocated elements, must use RT_ArrayAppend to add elements to the array.
With only Dim1 set to eg 1000, would create single dimension array of 1000 elements (0 -> 999), where RT_ArrayAppend can also be used.
With Dim1 and Dim2 greater than zero, would create a two dimensional array, where RT_ArrayAppend can NOT be used.
With Dim1, Dim2 and Dim3 greater than zero, would create a three dimensional array, where RT_ArrayAppend can NOT be used.
Will produce an error if Dim3 is non zero and Dim2 or Dim1 is zero, also error if Dim2 is non zero and Dim1 is zero.
It may be less efficient if you choose to set a dimension to 1 rather than 0, is eg better to use Dim1=100 than Dim1=100,Dim2=1,
also, as a two dimension array, you could not use RT_ArrayAppend.
StringLenMax, default 256(1 or more). Fixed Maximum string length excluding nul term. Error if string length exceeds.
Only used for Type=3 (string).
Returns total number of elements in array. All RT_ArrayXXXX() errors produce an error alert.

***
***
***

RT_ArrayGetDim(string FileName,int "Dim"=0)
Returns number of dimensions in array or the size of any 1 of the dimensions.
Filename, Array Filename, no default.
Dim, default 0. (Range 0 -> 3).
0, returns the number of dimensions in the array.
Invalid dimensions will return 0, eg RT_ArrayGetDim(FileName,Dim=2) on single dimension array return 0.
Error if Dim smaller than 0 or greater than 3.

***
***
***

RT_ArrayGetType(string FileName)
Filename, Array Filename, no default.
Returns int, Type as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNels(string FileName)
Filename, Array Filename, no default.
Returns int, total number of elements in array as set by RT_ArrayAlloc, or current number of elements if RT_ArrayAppend used to add
elements to end of single dimension array.

***
***
***

RT_ArrayGetElSize(string FileName)
Filename, Array Filename, no default.
Returns int, element size, Type 0(bool)=1, 1(int)=4, 2(float)=4, 3(string)=StringLenMax, 4(BIN)=1, as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNelMax(string FileName)
Filename, Array Filename, no default.
Returns int, maximum number of elements that could theoretically be stored in a single dimension array, based on
(maximum +ve integer - header size) / ElSize.

***
***
***

RT_ArrayGet(string FileName,int ix1,int "ix2",int "ix3")
Returns array element of variable Type as set in RT_ArrayAlloc. Type BIN returns an Int range 0 -> 255.
Filename, Array Filename, no default.
ixl, int, zero relative. 1st subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,1)-1.
ix2, int, zero relative. 2nd subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,2)-1.
Only valid if 2 or 3 dimensional array. For single dimension array, can omit, supply RT_Undefined(), or -1.
ix3, int, zero relative. 3rd subcript of array. Valid range 0 -> RT_ArrayGetDim(FileName,3)-1.
Only valid if 3 dimensional array. For 1 or 2 dimension array, can omit, supply RT_Undefined(), or -1.

***
***
***

RT_ArraySet(string FileName,Var,int ix1,int "ix2",int "ix3")
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc. (NOTE position in arg list changed)
ixl, int, zero relative. 1st subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,1)-1.
ix2, int, zero relative. 2nd subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,2)-1.
Only valid if 2 or 3 dimensional array. For single dimension array, can omit, supply RT_Undefined(), or -1.
ix3, int, zero relative. 3rd subcript of array. Valid range 0 -> RT_ArrayGetDim(FileName,3)-1.
Only valid if 3 dimensional array. For 1 or 2 dimension array, can omit, supply RT_Undefined(), or -1.
Returns total number of elements in array.

***
***
***

RT_ArrayAppend(string FileName,Var)
Adds a variable to end of single dimension array and increments the Nel count.
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in single dimension array.
Error if multi dimensional array.

***
***
***

RT_ArraySetAttrib(string FileName,int ix, Value)
There are 16 avalable attributes in the Array file header, that can be used for whatever purpose you like,
RT_ArrayAlloc() initializes all Attributes to type Int, 0.
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Value, Int or Float, The value that Attrib(ix) will be set to.
Returns Value. Error if type not of type Int or type Float.

***
***
***

RT_ArrayGetAttrib(string FileName,int ix)
There are 16 avalable attributes in the Array file header, that can be used for whatever purpose you like,
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Returns the value of the user set attribute Int or Float (or type Int 0 if not yet set).


Comments on interface implementation appreciated

StainlessS
10th November 2013, 00:27
Post #2 of 7

RT_Test_Array_1_Dim.Avs

# RT_Test_Array_1_Dim.Avs, 1 Dimensional array

/*
RT_ArrayAlloc(string FileName,int "Type"=1,int "Dim1"=0,int "Dim2"=0,,int "Dim3"=0,int "StringLenMax"=256)
RT_ArrayGetDim(string FileName,int "Dim"=0)
RT_ArrayGetType(string FileName)
RT_ArrayGetNels(string FileName)
RT_ArrayGetElSize(string FileName)
RT_ArrayGetNelMax(string FileName)
RT_ArrayGet(string FileName,int ix1,int "ix2",int "ix3")
RT_ArraySet(string FileName, var ,int ix1,int "ix2",int "ix3") # Var position in arg list changed
RT_ArrayAppend(string FileName, var)
RT_ArrayGetAttrib(string FileName,int ix)
RT_ArraySetAttrib(string FileName,int ix, value) # Value can be Int or Float.
*/

ARRAY="TestArray.ARR" # ARRAY name
START_TYPE = 0 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int)
END_TYPE = 4 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int) ## >= START_TYPE ##
NELS = 100000 # Inital Number of Array elements (init'ed to zero's) [Will be doubled by Append/Get]
STRINGLENMAX = 64 # Excluding Nul Term.
# Take care with NELS and STRINGLENMAX when processing Type=String.
# Approx string usage greater than (NELS * (STRINGLENMAX+1) * 6)
# String memory not released till Avisynth closure, no dead string garbage collection by Avisynth.
DELETE = True # True = Delete ARRAY file when done

ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ALPHA=ALPHA+ALPHA # Len 260
ALPHA=(STRINGLENMAX<STRLEN(ALPHA)) ? LeftStr(ALPHA,STRINGLENMAX) : ALPHA # cut down string manips and usage

TYPENAMES=RT_String("BOOL\nINT\nFLOAT\nSTRING\nBIN\n")

GScript("""
RT_DebugF("RT_Test_Arrayt_1_Dim.avs - Single Dimension Array")
TOTAL_START=RT_Timer()
RT_DebugF("")
For(TYPE=START_TYPE,END_TYPE) {
RT_DebugF("==============================")
TYPE_START=RT_Timer()
RT_ArrayAlloc(ARRAY,Type=TYPE,Dim1=NELS,stringlenmax=STRINGLENMAX)
STOP=RT_Timer()
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Nels = %d",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
RT_DebugF("Alloc Time = %.3f secs (Per element %f microsecs)",STOP-TYPE_START,1000000.0*(STOP-TYPE_START)/NELS)
RT_DebugF("\nCheck Init")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i)) {RT_DebugF("BOOL(%d) Init != False",i)}}
} Else if(TYPE==1) { # Int
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0) {RT_DebugF("INT(%d) Init != 0",i)}}
} Else if(TYPE==2) { # Float
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0.0) {RT_DebugF("FLOAT(%d) Init != 0.0",i)}}
} Else if(TYPE==3) { # String
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != ""){RT_DebugF("STRING(%d) Init != %c%c",i,34,34)}}
} Else if(TYPE==4) { # BIN
for(i=0,NELS-1) {if(RT_ArrayGet(ARRAY,i) != 0) {RT_DebugF("BIN(%d) Init != 0",i)}}
}
Try {RT_ArrayGet(ARRAY,NELS) RT_DebugF("Init END Check FAILED")} catch (err) {RT_DebugF("Init END Check Passed")}
STOP=RT_Timer()
RT_DebugF("Check Init Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Attributes Set/Get")
START=RT_Timer()
for(i=0,15) {
vs= (i % 2 == 0) ? i*1000 : i * PI # Test Int and Float Attributes
RT_ArraySetAttrib(ARRAY,i,vs)
vg = RT_ArrayGetAttrib(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d SetAttrib/GetAttrib Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
STOP=RT_Timer()
RT_DebugF("Check Attributes Set/Get = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Set only Time Test on %d Nels",NELS)
vs=Select(TYPE,True,42,42.0,RightStr(ALPHA + "_" + String(42),STRINGLENMAX) ,42)
START=RT_Timer()
for(i=0,NELS-1) {
RT_ArraySet(ARRAY,vs,i)
}
STOP=RT_Timer()
RT_DebugF("Check Set Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Get only Time Test on %d Nels",NELS)
START=RT_Timer()
for(i=0,NELS-1) {RT_ArrayGet(ARRAY,i)}
STOP=RT_Timer()
RT_DebugF("Check Get Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Set/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,NELS-1) {
vs = RT_BitTST(i,0) RT_ArraySet(ARRAY,vs,i) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==1) { # Int
for(i=0,NELS-1) {
vs = i RT_ArraySet(ARRAY,vs,i) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==2) { # Float
for(i=0,NELS-1) {
vs = Float(i) RT_ArraySet(ARRAY,vs,i) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==3) { # String
for(i=0,NELS-1) {
vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) RT_ArraySet(ARRAY,vs,i) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==4) { # BIN
for(i=0,NELS-1) {
vs = RT_BitAnd(i,$FF) RT_ArraySet(ARRAY,vs,i) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Compare Set/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Append/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=NELS,NELS*2-1) {
vs = RT_BitTST(i,0) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==1) { # Int
for(i=NELS,NELS*2-1) {
vs = i RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==2) { # Float
for(i=NELS,NELS*2-1) {
vs = Float(i) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==3) { # String
for(i=NELS,NELS*2-1) {
vs=RightStr(ALPHA + "_" + String(i),STRINGLENMAX) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
} Else if(TYPE==4) { # BIN
for(i=NELS,NELS*2-1) {
vs = RT_BitAnd(i,$FF) RT_ArrayAppend(ARRAY,vs) vg=RT_ArrayGet(ARRAY,i)
if(vs != vg) {
RT_DebugF("%d) TYPE=%d Append/Get Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
}
if(RT_ArrayGetNels(ARRAY) != NELS * 2) {
RT_DebugF("Final Check ERROR, RT_ArrayGetNels != NELS *2 (is %d)",RT_ArrayGetNels(ARRAY))
}
STOP=RT_Timer()
RT_DebugF("Check Compare Append/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("ALL Checks Done\n")
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Nels = %d (should have doubled)",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
STOP=RT_Timer()
RT_DebugF("Total Time Type=%d (%s) = %.3f secs",Type,RT_TxtGetLine(TYPENAMES,Type),STOP-TYPE_START)
}
(DELETE) ? RT_FileDelete(ARRAY) : NOP
TOTAL_STOP=RT_Timer()
RT_DebugF("SCRIPT TOTAL TIME = %.3f secs",TOTAL_STOP-TOTAL_START)
""")
return colorbars()

StainlessS
10th November 2013, 00:28
Post #3 of 7

RT_Test_Array_1_Dim.Log

00000001 0.00000000 RT_DebugF: RT_Test_Array_1_Dim.avs - Single Dimension Array
00000002 0.00013589 RT_DebugF:
00000003 0.00022477 RT_DebugF: ==============================
00000004 0.00121931 RT_DebugF: Type = 0 (BOOL)
00000005 0.00138569 RT_DebugF: Dimensions = 1
00000006 0.00155160 RT_DebugF: Nels = 100000
00000007 0.00171441 RT_DebugF: ElSize = 1
00000008 0.00195542 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000009 0.00204794 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000010 0.00213082 RT_DebugF:
00000011 0.00215442 RT_DebugF: Check Init
00000012 7.93041897 RT_DebugF: Init END Check Passed
00000013 7.93057775 RT_DebugF: Check Init Time = 7.937 secs (Per element 79.370003 microsecs)
00000014 7.93066311 RT_DebugF: Check Attributes Set/Get
00000015 7.93823862 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000016 7.93832684 RT_DebugF: Check Set only Time Test on 100000 Nels
00000017 19.25387573 RT_DebugF: Check Set Only Time = 11.328 secs (Per element 113.279991 microsecs)
00000018 19.25395966 RT_DebugF: Check Get only Time Test on 100000 Nels
00000019 27.35041046 RT_DebugF: Check Get Only Time = 8.094 secs (Per element 80.940002 microsecs)
00000020 27.35049629 RT_DebugF: Check Compare Set/Get
00000021 53.95354843 RT_DebugF: Check Compare Set/Get Time = 26.594 secs (Per element 265.940002 microsecs) [Including Data generation]
00000022 53.95363235 RT_DebugF: Check Compare Append/Get
00000023 81.46318817 RT_DebugF: Check Compare Append/Get Time = 27.515 secs (Per element 275.150055 microsecs) [Including Data generation]
00000024 81.46327209 RT_DebugF: ALL Checks Done
00000025 81.46329498 RT_DebugF:
00000026 81.46350861 RT_DebugF: Type = 0 (BOOL)
00000027 81.46367645 RT_DebugF: Dimensions = 1
00000028 81.46383667 RT_DebugF: Nels = 200000 (should have doubled)
00000029 81.46400452 RT_DebugF: ElSize = 1
00000030 81.46424103 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000031 81.46443939 RT_DebugF: Total Time Type=0 (BOOL) = 81.468 secs
00000032 81.46452332 RT_DebugF: ==============================
00000033 81.46635437 RT_DebugF: Type = 1 (INT)
00000034 81.46652985 RT_DebugF: Dimensions = 1
00000035 81.46669769 RT_DebugF: Nels = 100000
00000036 81.46685791 RT_DebugF: ElSize = 4
00000037 81.46710205 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000038 81.46719360 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000039 81.46727753 RT_DebugF:
00000040 81.46730042 RT_DebugF: Check Init
00000041 89.63143921 RT_DebugF: Init END Check Passed
00000042 89.63159180 RT_DebugF: Check Init Time = 8.172 secs (Per element 81.719971 microsecs)
00000043 89.63167572 RT_DebugF: Check Attributes Set/Get
00000044 89.63928223 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000045 89.63937378 RT_DebugF: Check Set only Time Test on 100000 Nels
00000046 101.12193298 RT_DebugF: Check Set Only Time = 11.485 secs (Per element 114.850014 microsecs)
00000047 101.12201691 RT_DebugF: Check Get only Time Test on 100000 Nels
00000048 109.27951813 RT_DebugF: Check Get Only Time = 8.156 secs (Per element 81.559982 microsecs)
00000049 109.27960205 RT_DebugF: Check Compare Set/Get
00000050 129.26173401 RT_DebugF: Check Compare Set/Get Time = 19.984 secs (Per element 199.840027 microsecs) [Including Data generation]
00000051 129.26181030 RT_DebugF: Check Compare Append/Get
00000052 150.20997620 RT_DebugF: Check Compare Append/Get Time = 20.953 secs (Per element 209.530014 microsecs) [Including Data generation]
00000053 150.21005249 RT_DebugF: ALL Checks Done
00000054 150.21008301 RT_DebugF:
00000055 150.21029663 RT_DebugF: Type = 1 (INT)
00000056 150.21044922 RT_DebugF: Dimensions = 1
00000057 150.21061707 RT_DebugF: Nels = 200000 (should have doubled)
00000058 150.21078491 RT_DebugF: ElSize = 4
00000059 150.21101379 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000060 150.21121216 RT_DebugF: Total Time Type=1 (INT) = 68.750 secs
00000061 150.21128845 RT_DebugF: ==============================
00000062 150.21311951 RT_DebugF: Type = 2 (FLOAT)
00000063 150.21328735 RT_DebugF: Dimensions = 1
00000064 150.21343994 RT_DebugF: Nels = 100000
00000065 150.21360779 RT_DebugF: ElSize = 4
00000066 150.21386719 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000067 150.21395874 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000068 150.21403503 RT_DebugF:
00000069 150.21406555 RT_DebugF: Check Init
00000070 158.67863464 RT_DebugF: Init END Check Passed
00000071 158.67880249 RT_DebugF: Check Init Time = 8.469 secs (Per element 84.689941 microsecs)
00000072 158.67887878 RT_DebugF: Check Attributes Set/Get
00000073 158.68649292 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.160065 microsecs)
00000074 158.68656921 RT_DebugF: Check Set only Time Test on 100000 Nels
00000075 170.10278320 RT_DebugF: Check Set Only Time = 11.406 secs (Per element 114.059914 microsecs)
00000076 170.10287476 RT_DebugF: Check Get only Time Test on 100000 Nels
00000077 178.25221252 RT_DebugF: Check Get Only Time = 8.156 secs (Per element 81.560059 microsecs)
00000078 178.25228882 RT_DebugF: Check Compare Set/Get
00000079 226.23529053 RT_DebugF: Check Compare Set/Get Time = 47.985 secs (Per element 479.850006 microsecs) [Including Data generation]
00000080 226.23538208 RT_DebugF: Check Compare Append/Get
00000081 275.02413940 RT_DebugF: Check Compare Append/Get Time = 48.796 secs (Per element 487.959869 microsecs) [Including Data generation]
00000082 275.02423096 RT_DebugF: ALL Checks Done
00000083 275.02423096 RT_DebugF:
00000084 275.02444458 RT_DebugF: Type = 2 (FLOAT)
00000085 275.02462769 RT_DebugF: Dimensions = 1
00000086 275.02478027 RT_DebugF: Nels = 200000 (should have doubled)
00000087 275.02493286 RT_DebugF: ElSize = 4
00000088 275.02517700 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000089 275.02536011 RT_DebugF: Total Time Type=2 (FLOAT) = 124.828 secs
00000090 275.02545166 RT_DebugF: ==============================
00000091 275.04098511 RT_DebugF: Type = 3 (STRING)
00000092 275.04116821 RT_DebugF: Dimensions = 1
00000093 275.04132080 RT_DebugF: Nels = 100000
00000094 275.04150391 RT_DebugF: ElSize = 64
00000095 275.04174805 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000096 275.04183960 RT_DebugF: Alloc Time = 0.016 secs (Per element 0.160217 microsecs)
00000097 275.04193115 RT_DebugF:
00000098 275.04193115 RT_DebugF: Check Init
00000099 283.48788452 RT_DebugF: Init END Check Passed
00000100 283.48803711 RT_DebugF: Check Init Time = 8.438 secs (Per element 84.379883 microsecs)
00000101 283.48812866 RT_DebugF: Check Attributes Set/Get
00000102 283.49581909 RT_DebugF: Check Attributes Set/Get = 0.015 secs (Per element 0.150146 microsecs)
00000103 283.49588013 RT_DebugF: Check Set only Time Test on 100000 Nels
00000104 295.08233643 RT_DebugF: Check Set Only Time = 11.578 secs (Per element 115.779716 microsecs)
00000105 295.08242798 RT_DebugF: Check Get only Time Test on 100000 Nels
00000106 303.34625244 RT_DebugF: Check Get Only Time = 8.266 secs (Per element 82.660217 microsecs)
00000107 303.34634399 RT_DebugF: Check Compare Set/Get
00000108 351.96871948 RT_DebugF: Check Compare Set/Get Time = 48.625 secs (Per element 486.250000 microsecs) [Including Data generation]
00000109 351.96878052 RT_DebugF: Check Compare Append/Get
00000110 401.32009888 RT_DebugF: Check Compare Append/Get Time = 49.359 secs (Per element 493.589813 microsecs) [Including Data generation]
00000111 401.32015991 RT_DebugF: ALL Checks Done
00000112 401.32019043 RT_DebugF:
00000113 401.32040405 RT_DebugF: Type = 3 (STRING)
00000114 401.32058716 RT_DebugF: Dimensions = 1
00000115 401.32073975 RT_DebugF: Nels = 200000 (should have doubled)
00000116 401.32089233 RT_DebugF: ElSize = 64
00000117 401.32113647 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000118 401.32131958 RT_DebugF: Total Time Type=3 (STRING) = 126.297 secs
00000119 401.32141113 RT_DebugF: ==============================
00000120 401.32302856 RT_DebugF: Type = 4 (BIN)
00000121 401.32318115 RT_DebugF: Dimensions = 1
00000122 401.32336426 RT_DebugF: Nels = 100000
00000123 401.32351685 RT_DebugF: ElSize = 1
00000124 401.32379150 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000125 401.32388306 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000126 401.32400513 RT_DebugF:
00000127 401.32403564 RT_DebugF: Check Init
00000128 409.84115601 RT_DebugF: Init END Check Passed
00000129 409.84130859 RT_DebugF: Check Init Time = 8.516 secs (Per element 85.160217 microsecs)
00000130 409.84136963 RT_DebugF: Check Attributes Set/Get
00000131 409.84899902 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.159912 microsecs)
00000132 409.84909058 RT_DebugF: Check Set only Time Test on 100000 Nels
00000133 421.16717529 RT_DebugF: Check Set Only Time = 11.312 secs (Per element 113.120117 microsecs)
00000134 421.16723633 RT_DebugF: Check Get only Time Test on 100000 Nels
00000135 429.34780884 RT_DebugF: Check Get Only Time = 8.188 secs (Per element 81.879883 microsecs)
00000136 429.34786987 RT_DebugF: Check Compare Set/Get
00000137 456.60794067 RT_DebugF: Check Compare Set/Get Time = 27.250 secs (Per element 272.500000 microsecs) [Including Data generation]
00000138 456.60800171 RT_DebugF: Check Compare Append/Get
00000139 484.82464600 RT_DebugF: Check Compare Append/Get Time = 28.218 secs (Per element 282.179871 microsecs) [Including Data generation]
00000140 484.82470703 RT_DebugF: ALL Checks Done
00000141 484.82473755 RT_DebugF:
00000142 484.82495117 RT_DebugF: Type = 4 (BIN)
00000143 484.82510376 RT_DebugF: Dimensions = 1
00000144 484.82528687 RT_DebugF: Nels = 200000 (should have doubled)
00000145 484.82543945 RT_DebugF: ElSize = 1
00000146 484.82568359 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000147 484.82586670 RT_DebugF: Total Time Type=4 (BIN) = 83.500 secs
00000148 484.82611084 RT_DebugF: SCRIPT TOTAL TIME = 484.843 secs

StainlessS
10th November 2013, 00:29
Post #4 of 7

RT_Test_Array_2_Dim.Avs

# RT_Test_Array_2_Dim.Avs, 2 Dimensional array

/*
RT_ArrayAlloc(string FileName,int "Type"=1,int "Dim1"=0,int "Dim2"=0,,int "Dim3"=0,int "StringLenMax"=256)
RT_ArrayGetDim(string FileName,int "Dim"=0)
RT_ArrayGetType(string FileName)
RT_ArrayGetNels(string FileName)
RT_ArrayGetElSize(string FileName)
RT_ArrayGetNelMax(string FileName)
RT_ArrayGet(string FileName,int ix1,int "ix2",int "ix3")
RT_ArraySet(string FileName, var ,int ix1,int "ix2",int "ix3") # Var position in arg list changed
RT_ArrayAppend(string FileName, var)
RT_ArrayGetAttrib(string FileName,int ix)
RT_ArraySetAttrib(string FileName,int ix, value) # Value can be Int or Float.
*/

ARRAY="TestArray.ARR" # ARRAY name
START_TYPE = 0 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int)
END_TYPE = 4 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int) ## >= START_TYPE ##
DIM1 = 10000 # Dim 1, Inital Number of Array elements
DIM2 = 10 # Dim 2
STRINGLENMAX = 64 # Excluding Nul Term.
DELETE = True # True = Delete ARRAY file when done

ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ALPHA=ALPHA+ALPHA # Len 260
ALPHA=(STRINGLENMAX<STRLEN(ALPHA)) ? LeftStr(ALPHA,STRINGLENMAX) : ALPHA # cut down string manips and usage

TYPENAMES=RT_String("BOOL\nINT\nFLOAT\nSTRING\nBIN\n")
NELS = DIM1 * DIM2

GScript("""
RT_DebugF("RT_Test_Array_2_Dim.avs - Two Dimension Array")
TOTAL_START=RT_Timer()
RT_DebugF("")
For(TYPE=START_TYPE,END_TYPE) {
RT_DebugF("==============================")
TYPE_START=RT_Timer()
RT_ArrayAlloc(ARRAY,Type=TYPE,Dim1=DIM1,Dim2=DIM2,stringlenmax=STRINGLENMAX)
STOP=RT_Timer()
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Dim1 = %d",RT_ArrayGetDim(ARRAY,1))
RT_DebugF("Dim2 = %d",RT_ArrayGetDim(ARRAY,2))
RT_DebugF("Nels = %d",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
RT_DebugF("Alloc Time = %.3f secs (Per element %f microsecs)",STOP-TYPE_START,1000000.0*(STOP-TYPE_START)/NELS)
RT_DebugF("\nCheck Init")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
if(RT_ArrayGet(ARRAY,i,j)) {RT_DebugF("BOOL(%d,%d) Init != False",i,j)}
}
}
} Else if(TYPE==1) { # Int
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
if(RT_ArrayGet(ARRAY,i,j) != 0) {RT_DebugF("INT(%d,%d) Init != 0",i,j)}
}
}
} Else if(TYPE==2) { # Float
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
if(RT_ArrayGet(ARRAY,i,j) != 0.0) {RT_DebugF("FLOAT(%d,%d) Init != 0.0",i,j)}
}
}
} Else if(TYPE==3) { # String
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
if(RT_ArrayGet(ARRAY,i,j) != ""){RT_DebugF("STRING(%d,%d) Init != %c%c",i,j,34,34)}
}
}
} Else if(TYPE==4) { # BIN
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
if(RT_ArrayGet(ARRAY,i,j) != 0) {RT_DebugF("BIN(%d,%d) Init != 0",i,j)}
}
}
}
Try {RT_ArrayGet(ARRAY,DIM1-1,DIM2) RT_DebugF("Init END Check1 FAILED")} catch (err) {RT_DebugF("Init END Check1 Passed")}
Try {RT_ArrayGet(ARRAY,DIM1,0) RT_DebugF("Init END Check2 FAILED")} catch (err) {RT_DebugF("Init END Check2 Passed")}
STOP=RT_Timer()
RT_DebugF("Check Init Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Attributes Set/Get")
START=RT_Timer()
for(i=0,15) {
vs= (i % 2 == 0) ? i*1000 : i * PI # Test Int and Float Attributes
RT_ArraySetAttrib(ARRAY,i,vs)
vg = RT_ArrayGetAttrib(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d SetAttrib/GetAttrib Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
STOP=RT_Timer()
RT_DebugF("Check Attributes Set/Get = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Set only Time Test on %d Nels",NELS)
vs=Select(TYPE,True,42,42.0,RightStr(ALPHA + "_" + String(42),STRINGLENMAX) ,42)
START=RT_Timer()
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
RT_ArraySet(ARRAY,vs,i,j)
}
}
STOP=RT_Timer()
RT_DebugF("Check Set Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Get only Time Test on %d Nels",NELS)
START=RT_Timer()
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
RT_ArrayGet(ARRAY,i,j)
}
}
STOP=RT_Timer()
RT_DebugF("Check Get Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Set/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
vs = RT_BitTST(i*DIM2+j,0) RT_ArraySet(ARRAY,vs,i,j) vg=RT_ArrayGet(ARRAY,i,j)
if(vs != vg) {
RT_DebugF("%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,TYPE,String(vs),String(vg))
}
}
}
} Else if(TYPE==1) { # Int
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
vs = i*DIM2+j RT_ArraySet(ARRAY,vs,i,j) vg=RT_ArrayGet(ARRAY,i,j)
if(vs != vg) {
RT_DebugF("%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,TYPE,String(vs),String(vg))
}
}
}
} Else if(TYPE==2) { # Float
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
vs = Float(i*DIM2+j) RT_ArraySet(ARRAY,vs,i,j) vg=RT_ArrayGet(ARRAY,i,j)
if(vs != vg) {
RT_DebugF("%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,TYPE,String(vs),String(vg))
}
}
}
} Else if(TYPE==3) { # String
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
vs=RightStr(ALPHA + "_" + String(i*DIM2+j),STRINGLENMAX) RT_ArraySet(ARRAY,vs,i,j) vg=RT_ArrayGet(ARRAY,i,j)
if(vs != vg) {
RT_DebugF("%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,TYPE,String(vs),String(vg))
}
}
}
} Else if(TYPE==4) { # BIN
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
vs = RT_BitAnd(i*DIM2+j,$FF) RT_ArraySet(ARRAY,vs,i,j) vg=RT_ArrayGet(ARRAY,i,j)
if(vs != vg) {
RT_DebugF("%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,TYPE,String(vs),String(vg))
}
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Compare Set/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("ALL Checks Done\n")
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Dim1 = %d",RT_ArrayGetDim(ARRAY,1))
RT_DebugF("Dim2 = %d",RT_ArrayGetDim(ARRAY,2))
RT_DebugF("Nels = %d (Not doubled, Cannot append to multi-dim array)",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
STOP=RT_Timer()
RT_DebugF("Total Time Type=%d (%s) = %.3f secs",Type,RT_TxtGetLine(TYPENAMES,Type),STOP-TYPE_START)
}
(DELETE) ? RT_FileDelete(ARRAY) : NOP
TOTAL_STOP=RT_Timer()
RT_DebugF("SCRIPT TOTAL TIME = %.3f secs",TOTAL_STOP-TOTAL_START)
""")
return colorbars()

StainlessS
10th November 2013, 00:30
Post #5 of 7

RT_Test_Array_2_Dim.Log

00000001 0.00000000 RT_DebugF: RT_Test_Array_2_Dim.avs - Two Dimension Array
00000002 0.00013633 RT_DebugF:
00000003 0.00022618 RT_DebugF: ==============================
00000004 0.00136300 RT_DebugF: Type = 0 (BOOL)
00000005 0.00152955 RT_DebugF: Dimensions = 2
00000006 0.00169800 RT_DebugF: Dim1 = 10000
00000007 0.00189691 RT_DebugF: Dim2 = 10
00000008 0.00206046 RT_DebugF: Nels = 100000
00000009 0.00222277 RT_DebugF: ElSize = 1
00000010 0.00246191 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000011 0.00255518 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000012 0.00263816 RT_DebugF:
00000013 0.00266201 RT_DebugF: Check Init
00000014 8.12602615 RT_DebugF: Init END Check1 Passed
00000015 8.12623787 RT_DebugF: Init END Check2 Passed
00000016 8.12639523 RT_DebugF: Check Init Time = 8.125 secs (Per element 81.250000 microsecs)
00000017 8.12647915 RT_DebugF: Check Attributes Set/Get
00000018 8.13418102 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000019 8.13426781 RT_DebugF: Check Set only Time Test on 100000 Nels
00000020 20.33507538 RT_DebugF: Check Set Only Time = 12.203 secs (Per element 122.029991 microsecs)
00000021 20.33515930 RT_DebugF: Check Get only Time Test on 100000 Nels
00000022 28.66847420 RT_DebugF: Check Get Only Time = 8.343 secs (Per element 83.430008 microsecs)
00000023 28.66855431 RT_DebugF: Check Compare Set/Get
00000024 57.08416367 RT_DebugF: Check Compare Set/Get Time = 28.407 secs (Per element 284.070007 microsecs) [Including Data generation]
00000025 57.08424377 RT_DebugF: ALL Checks Done
00000026 57.08427048 RT_DebugF:
00000027 57.08448792 RT_DebugF: Type = 0 (BOOL)
00000028 57.08465195 RT_DebugF: Dimensions = 2
00000029 57.08481979 RT_DebugF: Dim1 = 10000
00000030 57.08498383 RT_DebugF: Dim2 = 10
00000031 57.08514786 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000032 57.08531570 RT_DebugF: ElSize = 1
00000033 57.08555603 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000034 57.08574295 RT_DebugF: Total Time Type=0 (BOOL) = 57.078 secs
00000035 57.08583450 RT_DebugF: ==============================
00000036 57.08751297 RT_DebugF: Type = 1 (INT)
00000037 57.08768082 RT_DebugF: Dimensions = 2
00000038 57.08785248 RT_DebugF: Dim1 = 10000
00000039 57.08801651 RT_DebugF: Dim2 = 10
00000040 57.08818817 RT_DebugF: Nels = 100000
00000041 57.08837891 RT_DebugF: ElSize = 4
00000042 57.08861923 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000043 57.08871460 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000044 57.08880234 RT_DebugF:
00000045 57.08882523 RT_DebugF: Check Init
00000046 65.49828339 RT_DebugF: Init END Check1 Passed
00000047 65.49848938 RT_DebugF: Init END Check2 Passed
00000048 65.49865723 RT_DebugF: Check Init Time = 8.407 secs (Per element 84.070007 microsecs)
00000049 65.49874115 RT_DebugF: Check Attributes Set/Get
00000050 65.50650787 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000051 65.50659180 RT_DebugF: Check Set only Time Test on 100000 Nels
00000052 77.87017822 RT_DebugF: Check Set Only Time = 12.375 secs (Per element 123.750000 microsecs)
00000053 77.87026215 RT_DebugF: Check Get only Time Test on 100000 Nels
00000054 86.22363281 RT_DebugF: Check Get Only Time = 8.343 secs (Per element 83.430023 microsecs)
00000055 86.22371674 RT_DebugF: Check Compare Set/Get
00000056 107.68625641 RT_DebugF: Check Compare Set/Get Time = 21.469 secs (Per element 214.689941 microsecs) [Including Data generation]
00000057 107.68633270 RT_DebugF: ALL Checks Done
00000058 107.68635559 RT_DebugF:
00000059 107.68656921 RT_DebugF: Type = 1 (INT)
00000060 107.68673706 RT_DebugF: Dimensions = 2
00000061 107.68689728 RT_DebugF: Dim1 = 10000
00000062 107.68707275 RT_DebugF: Dim2 = 10
00000063 107.68723297 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000064 107.68740082 RT_DebugF: ElSize = 4
00000065 107.68763733 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000066 107.68782806 RT_DebugF: Total Time Type=1 (INT) = 50.609 secs
00000067 107.68791962 RT_DebugF: ==============================
00000068 107.68959045 RT_DebugF: Type = 2 (FLOAT)
00000069 107.68975830 RT_DebugF: Dimensions = 2
00000070 107.68992615 RT_DebugF: Dim1 = 10000
00000071 107.69011688 RT_DebugF: Dim2 = 10
00000072 107.69028473 RT_DebugF: Nels = 100000
00000073 107.69044495 RT_DebugF: ElSize = 4
00000074 107.69068909 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000075 107.69078064 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000076 107.69086456 RT_DebugF:
00000077 107.69088745 RT_DebugF: Check Init
00000078 116.36470032 RT_DebugF: Init END Check1 Passed
00000079 116.36490631 RT_DebugF: Init END Check2 Passed
00000080 116.36506653 RT_DebugF: Check Init Time = 8.672 secs (Per element 86.720047 microsecs)
00000081 116.36515045 RT_DebugF: Check Attributes Set/Get
00000082 116.37288666 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.159988 microsecs)
00000083 116.37297058 RT_DebugF: Check Set only Time Test on 100000 Nels
00000084 128.71505737 RT_DebugF: Check Set Only Time = 12.343 secs (Per element 123.430023 microsecs)
00000085 128.71514893 RT_DebugF: Check Get only Time Test on 100000 Nels
00000086 137.08207703 RT_DebugF: Check Get Only Time = 8.360 secs (Per element 83.600006 microsecs)
00000087 137.08215332 RT_DebugF: Check Compare Set/Get
00000088 186.00663757 RT_DebugF: Check Compare Set/Get Time = 48.937 secs (Per element 489.369965 microsecs) [Including Data generation]
00000089 186.00671387 RT_DebugF: ALL Checks Done
00000090 186.00672913 RT_DebugF:
00000091 186.00694275 RT_DebugF: Type = 2 (FLOAT)
00000092 186.00711060 RT_DebugF: Dimensions = 2
00000093 186.00727844 RT_DebugF: Dim1 = 10000
00000094 186.00744629 RT_DebugF: Dim2 = 10
00000095 186.00761414 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000096 186.00776672 RT_DebugF: ElSize = 4
00000097 186.00801086 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000098 186.00819397 RT_DebugF: Total Time Type=2 (FLOAT) = 78.328 secs
00000099 186.00828552 RT_DebugF: ==============================
00000100 186.02537537 RT_DebugF: Type = 3 (STRING)
00000101 186.02552795 RT_DebugF: Dimensions = 2
00000102 186.02571106 RT_DebugF: Dim1 = 10000
00000103 186.02586365 RT_DebugF: Dim2 = 10
00000104 186.02603149 RT_DebugF: Nels = 100000
00000105 186.02619934 RT_DebugF: ElSize = 64
00000106 186.02644348 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000107 186.02655029 RT_DebugF: Alloc Time = 0.016 secs (Per element 0.160065 microsecs)
00000108 186.02664185 RT_DebugF:
00000109 186.02667236 RT_DebugF: Check Init
00000110 194.68681335 RT_DebugF: Init END Check1 Passed
00000111 194.68702698 RT_DebugF: Init END Check2 Passed
00000112 194.68717957 RT_DebugF: Check Init Time = 8.656 secs (Per element 86.559914 microsecs)
00000113 194.68727112 RT_DebugF: Check Attributes Set/Get
00000114 194.69503784 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.160065 microsecs)
00000115 194.69512939 RT_DebugF: Check Set only Time Test on 100000 Nels
00000116 207.24955750 RT_DebugF: Check Set Only Time = 12.547 secs (Per element 125.469971 microsecs)
00000117 207.24963379 RT_DebugF: Check Get only Time Test on 100000 Nels
00000118 215.72695923 RT_DebugF: Check Get Only Time = 8.484 secs (Per element 84.839943 microsecs)
00000119 215.72705078 RT_DebugF: Check Compare Set/Get
00000120 265.41159058 RT_DebugF: Check Compare Set/Get Time = 49.687 secs (Per element 496.869965 microsecs) [Including Data generation]
00000121 265.41171265 RT_DebugF: ALL Checks Done
00000122 265.41174316 RT_DebugF:
00000123 265.41195679 RT_DebugF: Type = 3 (STRING)
00000124 265.41210938 RT_DebugF: Dimensions = 2
00000125 265.41226196 RT_DebugF: Dim1 = 10000
00000126 265.41244507 RT_DebugF: Dim2 = 10
00000127 265.41259766 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000128 265.41278076 RT_DebugF: ElSize = 64
00000129 265.41302490 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000130 265.41320801 RT_DebugF: Total Time Type=3 (STRING) = 79.406 secs
00000131 265.41329956 RT_DebugF: ==============================
00000132 265.41476440 RT_DebugF: Type = 4 (BIN)
00000133 265.41491699 RT_DebugF: Dimensions = 2
00000134 265.41510010 RT_DebugF: Dim1 = 10000
00000135 265.41528320 RT_DebugF: Dim2 = 10
00000136 265.41546631 RT_DebugF: Nels = 100000
00000137 265.41567993 RT_DebugF: ElSize = 1
00000138 265.41592407 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000139 265.41601563 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000140 265.41610718 RT_DebugF:
00000141 265.41613770 RT_DebugF: Check Init
00000142 274.11859131 RT_DebugF: Init END Check1 Passed
00000143 274.11880493 RT_DebugF: Init END Check2 Passed
00000144 274.11895752 RT_DebugF: Check Init Time = 8.704 secs (Per element 87.040100 microsecs)
00000145 274.11901855 RT_DebugF: Check Attributes Set/Get
00000146 274.12680054 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000147 274.12689209 RT_DebugF: Check Set only Time Test on 100000 Nels
00000148 286.32312012 RT_DebugF: Check Set Only Time = 12.188 secs (Per element 121.879883 microsecs)
00000149 286.32318115 RT_DebugF: Check Get only Time Test on 100000 Nels
00000150 294.69894409 RT_DebugF: Check Get Only Time = 8.375 secs (Per element 83.750000 microsecs)
00000151 294.69900513 RT_DebugF: Check Compare Set/Get
00000152 323.51010132 RT_DebugF: Check Compare Set/Get Time = 28.812 secs (Per element 288.120117 microsecs) [Including Data generation]
00000153 323.51019287 RT_DebugF: ALL Checks Done
00000154 323.51022339 RT_DebugF:
00000155 323.51043701 RT_DebugF: Type = 4 (BIN)
00000156 323.51058960 RT_DebugF: Dimensions = 2
00000157 323.51074219 RT_DebugF: Dim1 = 10000
00000158 323.51092529 RT_DebugF: Dim2 = 10
00000159 323.51107788 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000160 323.51126099 RT_DebugF: ElSize = 1
00000161 323.51150513 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000162 323.51168823 RT_DebugF: Total Time Type=4 (BIN) = 58.094 secs
00000163 323.51190186 RT_DebugF: SCRIPT TOTAL TIME = 323.515 secs

StainlessS
10th November 2013, 00:32
Post #6 of 7

RT_Test_Array_3_Dim.Avs

# RT_Test_Array_3_Dim.Avs, 3 Dimensional array

/*
RT_ArrayAlloc(string FileName,int "Type"=1,int "Dim1"=0,int "Dim2"=0,,int "Dim3"=0,int "StringLenMax"=256)
RT_ArrayGetDim(string FileName,int "Dim"=0)
RT_ArrayGetType(string FileName)
RT_ArrayGetNels(string FileName)
RT_ArrayGetElSize(string FileName)
RT_ArrayGetNelMax(string FileName)
RT_ArrayGet(string FileName,int ix1,int "ix2",int "ix3")
RT_ArraySet(string FileName, var ,int ix1,int "ix2",int "ix3") # Var position in arg list changed
RT_ArrayAppend(string FileName, var)
RT_ArrayGetAttrib(string FileName,int ix)
RT_ArraySetAttrib(string FileName,int ix, value) # Value can be Int or Float.
*/

ARRAY="TestArray.ARR" # ARRAY name
START_TYPE = 0 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int)
END_TYPE = 4 # 0=Bool,1=Int,2=Float,3=String,4=BIN(BYTE sized int) ## >= START_TYPE ##
DIM1 = 500 # Dim 1, Inital Number of Array elements
DIM2 = 20 # Dim 2
DIM3 = 10 # Dim 3
STRINGLENMAX = 64 # Excluding Nul Term.
DELETE = True # True = Delete ARRAY file when done

ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ"
ALPHA=ALPHA+ALPHA # Len 260
ALPHA=(STRINGLENMAX<STRLEN(ALPHA)) ? LeftStr(ALPHA,STRINGLENMAX) : ALPHA # cut down string manips and usage

TYPENAMES=RT_String("BOOL\nINT\nFLOAT\nSTRING\nBIN\n")
NELS = DIM1 * DIM2 * DIM3

GScript("""
RT_DebugF("RT_Test_Array_3_Dim.avs - Three Dimension Array")
TOTAL_START=RT_Timer()
RT_DebugF("")
For(TYPE=START_TYPE,END_TYPE) {
RT_DebugF("==============================")
TYPE_START=RT_Timer()
RT_ArrayAlloc(ARRAY,Type=TYPE,Dim1=DIM1,Dim2=DIM2,Dim3=DIM3,stringlenmax=STRINGLENMAX)
STOP=RT_Timer()
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Dim1 = %d",RT_ArrayGetDim(ARRAY,1))
RT_DebugF("Dim2 = %d",RT_ArrayGetDim(ARRAY,2))
RT_DebugF("Dim3 = %d",RT_ArrayGetDim(ARRAY,3))
RT_DebugF("Nels = %d",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
RT_DebugF("Alloc Time = %.3f secs (Per element %f microsecs)",STOP-TYPE_START,1000000.0*(STOP-TYPE_START)/NELS)
RT_DebugF("\nCheck Init")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
if(RT_ArrayGet(ARRAY,i,j,k)) {RT_DebugF("BOOL(%d,%d,%d) Init != False",i,j,k)}
}
}
}
} Else if(TYPE==1) { # Int
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
if(RT_ArrayGet(ARRAY,i,j,k) != 0) {RT_DebugF("INT(%d,%d,%d) Init != 0",i,j,k)}
}
}
}
} Else if(TYPE==2) { # Float
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
if(RT_ArrayGet(ARRAY,i,j,k) != 0.0) {RT_DebugF("FLOAT(%d,%d,%d) Init != 0.0",i,j,k)}
}
}
}
} Else if(TYPE==3) { # String
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
if(RT_ArrayGet(ARRAY,i,j,k) != ""){RT_DebugF("STRING(%d,%d,%d) Init != %c%c",i,j,k,34,34)}
}
}
}
} Else if(TYPE==4) { # BIN
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
if(RT_ArrayGet(ARRAY,i,j,k) != 0) {RT_DebugF("BIN(%d,%d,%d) Init != 0",i,j,k)}
}
}
}
}
Try {RT_ArrayGet(ARRAY,DIM1-1,DIM2-1,DIM3) RT_DebugF("Init END Check1 FAILED")} catch (err) {RT_DebugF("Init END Check1 Passed")}
Try {RT_ArrayGet(ARRAY,DIM1-1,DIM2,0) RT_DebugF("Init END Check2 FAILED")} catch (err) {RT_DebugF("Init END Check2 Passed")}
Try {RT_ArrayGet(ARRAY,DIM1,0,0) RT_DebugF("Init END Check3 FAILED")} catch (err) {RT_DebugF("Init END Check3 Passed")}
STOP=RT_Timer()
RT_DebugF("Check Init Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Attributes Set/Get")
START=RT_Timer()
for(i=0,15) {
vs= (i % 2 == 0) ? i*1000 : i * PI # Test Int and Float Attributes
RT_ArraySetAttrib(ARRAY,i,vs)
vg = RT_ArrayGetAttrib(ARRAY,i)
if(vg != vs) {
RT_DebugF("%d) TYPE=%d SetAttrib/GetAttrib Error, Set = %s Get = %s",i,TYPE,String(vs),String(vg))
}
}
STOP=RT_Timer()
RT_DebugF("Check Attributes Set/Get = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Set only Time Test on %d Nels",NELS)
vs=Select(TYPE,True,42,42.0,RightStr(ALPHA + "_" + String(42),STRINGLENMAX) ,42)
START=RT_Timer()
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
RT_ArraySet(ARRAY,vs,i,j,k)
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Set Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Get only Time Test on %d Nels",NELS)
START=RT_Timer()
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
RT_ArrayGet(ARRAY,i,j,k)
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Get Only Time = %.3f secs (Per element %f microsecs)",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("Check Compare Set/Get")
START=RT_Timer()
if(TYPE==0) { # Bool
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
vs = RT_BitTST((i*DIM2+j)*DIM3+k,0) RT_ArraySet(ARRAY,vs,i,j,k) vg=RT_ArrayGet(ARRAY,i,j,k)
if(vs != vg) {
RT_DebugF("%d,%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,k,TYPE,String(vs),String(vg))
}
}
}
}
} Else if(TYPE==1) { # Int
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
vs = (i*DIM2+j)*DIM3+k RT_ArraySet(ARRAY,vs,i,j,k) vg=RT_ArrayGet(ARRAY,i,j,k)
if(vs != vg) {
RT_DebugF("%d,%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,k,TYPE,String(vs),String(vg))
}
}
}
}
} Else if(TYPE==2) { # Float
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
vs = Float((i*DIM2+j)*DIM3+k) RT_ArraySet(ARRAY,vs,i,j,k) vg=RT_ArrayGet(ARRAY,i,j,k)
if(vs != vg) {
RT_DebugF("%d,%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,k,TYPE,String(vs),String(vg))
}
}
}
}
} Else if(TYPE==3) { # String
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
vs=RightStr(ALPHA + "_" + String((i*DIM2+j)*DIM3+k),STRINGLENMAX) RT_ArraySet(ARRAY,vs,i,j,k) vg=RT_ArrayGet(ARRAY,i,j,k)
if(vs != vg) {
RT_DebugF("%d,%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,k,TYPE,String(vs),String(vg))
}
}
}
}
} Else if(TYPE==4) { # BIN
for(i=0,DIM1-1) {
for(j=0,DIM2-1) {
for(k=0,DIM3-1) {
vs = RT_BitAnd((i*DIM2+j)*DIM3+k,$FF) RT_ArraySet(ARRAY,vs,i,j,k) vg=RT_ArrayGet(ARRAY,i,j,k)
if(vs != vg) {
RT_DebugF("%d,%d,%d) TYPE=%d Set/Get Error, Set = %s Get = %s",i,j,k,TYPE,String(vs),String(vg))
}
}
}
}
}
STOP=RT_Timer()
RT_DebugF("Check Compare Set/Get Time = %.3f secs (Per element %f microsecs) [Including Data generation]",STOP-START,1000000.0*(STOP-START)/NELS)
RT_DebugF("ALL Checks Done\n")
RT_DebugF("Type = %d (%s)",RT_ArrayGetType(ARRAY),RT_TxtGetLine(TYPENAMES,Type))
RT_DebugF("Dimensions = %d",RT_ArrayGetDim(ARRAY))
RT_DebugF("Dim1 = %d",RT_ArrayGetDim(ARRAY,1))
RT_DebugF("Dim2 = %d",RT_ArrayGetDim(ARRAY,2))
RT_DebugF("Dim3 = %d",RT_ArrayGetDim(ARRAY,3))
RT_DebugF("Nels = %d (Not doubled, Cannot append to multi-dim array)",RT_ArrayGetNels(ARRAY))
RT_DebugF("ElSize = %d",RT_ArrayGetElSize(ARRAY))
RT_DebugF("NelMax = %d ($%X)",RT_ArrayGetNelMax(ARRAY),RT_ArrayGetNelMax(ARRAY))
STOP=RT_Timer()
RT_DebugF("Total Time Type=%d (%s) = %.3f secs",Type,RT_TxtGetLine(TYPENAMES,Type),STOP-TYPE_START)
}
(DELETE) ? RT_FileDelete(ARRAY) : NOP
TOTAL_STOP=RT_Timer()
RT_DebugF("SCRIPT TOTAL TIME = %.3f secs",TOTAL_STOP-TOTAL_START)
""")
return colorbars()

StainlessS
10th November 2013, 00:33
Post #7 of 7

RT_Test_Array_3_Dim.Log

00000001 0.00000000 RT_DebugF: RT_Test_Array_3_Dim.avs - Three Dimension Array
00000002 0.00014211 RT_DebugF:
00000003 0.00023225 RT_DebugF: ==============================
00000004 0.00131004 RT_DebugF: Type = 0 (BOOL)
00000005 0.00147912 RT_DebugF: Dimensions = 3
00000006 0.00164855 RT_DebugF: Dim1 = 500
00000007 0.00181547 RT_DebugF: Dim2 = 20
00000008 0.00198199 RT_DebugF: Dim3 = 10
00000009 0.00218009 RT_DebugF: Nels = 100000
00000010 0.00234457 RT_DebugF: ElSize = 1
00000011 0.00258637 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000012 0.00267946 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000013 0.00276241 RT_DebugF:
00000014 0.00278579 RT_DebugF: Check Init
00000015 8.27883625 RT_DebugF: Init END Check1 Passed
00000016 8.27904987 RT_DebugF: Init END Check2 Passed
00000017 8.27925873 RT_DebugF: Init END Check3 Passed
00000018 8.27941895 RT_DebugF: Check Init Time = 8.281 secs (Per element 82.809998 microsecs)
00000019 8.27950382 RT_DebugF: Check Attributes Set/Get
00000020 8.28724003 RT_DebugF: Check Attributes Set/Get = 0.015 secs (Per element 0.149994 microsecs)
00000021 8.28732872 RT_DebugF: Check Set only Time Test on 100000 Nels
00000022 20.20360184 RT_DebugF: Check Set Only Time = 11.907 secs (Per element 119.070000 microsecs)
00000023 20.20368767 RT_DebugF: Check Get only Time Test on 100000 Nels
00000024 28.68160629 RT_DebugF: Check Get Only Time = 8.484 secs (Per element 84.840012 microsecs)
00000025 28.68168640 RT_DebugF: Check Compare Set/Get
00000026 56.60816193 RT_DebugF: Check Compare Set/Get Time = 27.922 secs (Per element 279.220001 microsecs) [Including Data generation]
00000027 56.60824585 RT_DebugF: ALL Checks Done
00000028 56.60826874 RT_DebugF:
00000029 56.60848236 RT_DebugF: Type = 0 (BOOL)
00000030 56.60865021 RT_DebugF: Dimensions = 3
00000031 56.60882187 RT_DebugF: Dim1 = 500
00000032 56.60898590 RT_DebugF: Dim2 = 20
00000033 56.60914993 RT_DebugF: Dim3 = 10
00000034 56.60932159 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000035 56.60948563 RT_DebugF: ElSize = 1
00000036 56.60972977 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000037 56.60992432 RT_DebugF: Total Time Type=0 (BOOL) = 56.609 secs
00000038 56.61000824 RT_DebugF: ==============================
00000039 56.61172485 RT_DebugF: Type = 1 (INT)
00000040 56.61191177 RT_DebugF: Dimensions = 3
00000041 56.61207962 RT_DebugF: Dim1 = 500
00000042 56.61225128 RT_DebugF: Dim2 = 20
00000043 56.61241913 RT_DebugF: Dim3 = 10
00000044 56.61258316 RT_DebugF: Nels = 100000
00000045 56.61275101 RT_DebugF: ElSize = 4
00000046 56.61299133 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000047 56.61309433 RT_DebugF: Alloc Time = 0.016 secs (Per element 0.159988 microsecs)
00000048 56.61317444 RT_DebugF:
00000049 56.61319733 RT_DebugF: Check Init
00000050 65.18122864 RT_DebugF: Init END Check1 Passed
00000051 65.18144226 RT_DebugF: Init END Check2 Passed
00000052 65.18164825 RT_DebugF: Init END Check3 Passed
00000053 65.18180847 RT_DebugF: Check Init Time = 8.562 secs (Per element 85.619957 microsecs)
00000054 65.18190002 RT_DebugF: Check Attributes Set/Get
00000055 65.18953705 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.160065 microsecs)
00000056 65.18962860 RT_DebugF: Check Set only Time Test on 100000 Nels
00000057 77.02680206 RT_DebugF: Check Set Only Time = 11.828 secs (Per element 118.279953 microsecs)
00000058 77.02688599 RT_DebugF: Check Get only Time Test on 100000 Nels
00000059 85.54342651 RT_DebugF: Check Get Only Time = 8.515 secs (Per element 85.149986 microsecs)
00000060 85.54350281 RT_DebugF: Check Compare Set/Get
00000061 107.05323029 RT_DebugF: Check Compare Set/Get Time = 21.516 secs (Per element 215.159973 microsecs) [Including Data generation]
00000062 107.05330658 RT_DebugF: ALL Checks Done
00000063 107.05332947 RT_DebugF:
00000064 107.05354309 RT_DebugF: Type = 1 (INT)
00000065 107.05371857 RT_DebugF: Dimensions = 3
00000066 107.05387878 RT_DebugF: Dim1 = 500
00000067 107.05404663 RT_DebugF: Dim2 = 20
00000068 107.05421448 RT_DebugF: Dim3 = 10
00000069 107.05437469 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000070 107.05453491 RT_DebugF: ElSize = 4
00000071 107.05478668 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000072 107.05496979 RT_DebugF: Total Time Type=1 (INT) = 50.453 secs
00000073 107.05506134 RT_DebugF: ==============================
00000074 107.05671692 RT_DebugF: Type = 2 (FLOAT)
00000075 107.05688477 RT_DebugF: Dimensions = 3
00000076 107.05705261 RT_DebugF: Dim1 = 500
00000077 107.05722046 RT_DebugF: Dim2 = 20
00000078 107.05738068 RT_DebugF: Dim3 = 10
00000079 107.05754852 RT_DebugF: Nels = 100000
00000080 107.05771637 RT_DebugF: ElSize = 4
00000081 107.05796051 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000082 107.05805969 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000083 107.05814362 RT_DebugF:
00000084 107.05816650 RT_DebugF: Check Init
00000085 115.89083862 RT_DebugF: Init END Check1 Passed
00000086 115.89105225 RT_DebugF: Init END Check2 Passed
00000087 115.89126587 RT_DebugF: Init END Check3 Passed
00000088 115.89143372 RT_DebugF: Check Init Time = 8.844 secs (Per element 88.440018 microsecs)
00000089 115.89151001 RT_DebugF: Check Attributes Set/Get
00000090 115.89917755 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000091 115.89926147 RT_DebugF: Check Set only Time Test on 100000 Nels
00000092 127.76137543 RT_DebugF: Check Set Only Time = 11.859 secs (Per element 118.590012 microsecs)
00000093 127.76145935 RT_DebugF: Check Get only Time Test on 100000 Nels
00000094 136.27801514 RT_DebugF: Check Get Only Time = 8.516 secs (Per element 85.160057 microsecs)
00000095 136.27810669 RT_DebugF: Check Compare Set/Get
00000096 185.36102295 RT_DebugF: Check Compare Set/Get Time = 49.094 secs (Per element 490.939972 microsecs) [Including Data generation]
00000097 185.36109924 RT_DebugF: ALL Checks Done
00000098 185.36112976 RT_DebugF:
00000099 185.36134338 RT_DebugF: Type = 2 (FLOAT)
00000100 185.36149597 RT_DebugF: Dimensions = 3
00000101 185.36167908 RT_DebugF: Dim1 = 500
00000102 185.36184692 RT_DebugF: Dim2 = 20
00000103 185.36201477 RT_DebugF: Dim3 = 10
00000104 185.36218262 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000105 185.36233521 RT_DebugF: ElSize = 4
00000106 185.36257935 RT_DebugF: NelMax = 536870847 ($1FFFFFBF)
00000107 185.36276245 RT_DebugF: Total Time Type=2 (FLOAT) = 78.313 secs
00000108 185.36285400 RT_DebugF: ==============================
00000109 185.38035583 RT_DebugF: Type = 3 (STRING)
00000110 185.38052368 RT_DebugF: Dimensions = 3
00000111 185.38069153 RT_DebugF: Dim1 = 500
00000112 185.38085938 RT_DebugF: Dim2 = 20
00000113 185.38102722 RT_DebugF: Dim3 = 10
00000114 185.38119507 RT_DebugF: Nels = 100000
00000115 185.38136292 RT_DebugF: ElSize = 64
00000116 185.38160706 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000117 185.38171387 RT_DebugF: Alloc Time = 0.015 secs (Per element 0.149994 microsecs)
00000118 185.38179016 RT_DebugF:
00000119 185.38182068 RT_DebugF: Check Init
00000120 194.16348267 RT_DebugF: Init END Check1 Passed
00000121 194.16371155 RT_DebugF: Init END Check2 Passed
00000122 194.16390991 RT_DebugF: Init END Check3 Passed
00000123 194.16407776 RT_DebugF: Check Init Time = 8.781 secs (Per element 87.810059 microsecs)
00000124 194.16415405 RT_DebugF: Check Attributes Set/Get
00000125 194.17181396 RT_DebugF: Check Attributes Set/Get = 0.016 secs (Per element 0.159912 microsecs)
00000126 194.17190552 RT_DebugF: Check Set only Time Test on 100000 Nels
00000127 206.27981567 RT_DebugF: Check Set Only Time = 12.109 secs (Per element 121.090088 microsecs)
00000128 206.27989197 RT_DebugF: Check Get only Time Test on 100000 Nels
00000129 214.92962646 RT_DebugF: Check Get Only Time = 8.641 secs (Per element 86.409912 microsecs)
00000130 214.92970276 RT_DebugF: Check Compare Set/Get
00000131 264.40823364 RT_DebugF: Check Compare Set/Get Time = 49.484 secs (Per element 494.839905 microsecs) [Including Data generation]
00000132 264.40829468 RT_DebugF: ALL Checks Done
00000133 264.40832520 RT_DebugF:
00000134 264.40853882 RT_DebugF: Type = 3 (STRING)
00000135 264.40869141 RT_DebugF: Dimensions = 3
00000136 264.40887451 RT_DebugF: Dim1 = 500
00000137 264.40902710 RT_DebugF: Dim2 = 20
00000138 264.40921021 RT_DebugF: Dim3 = 10
00000139 264.40936279 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000140 264.40954590 RT_DebugF: ElSize = 64
00000141 264.40975952 RT_DebugF: NelMax = 33554427 ($1FFFFFB)
00000142 264.40997314 RT_DebugF: Total Time Type=3 (STRING) = 79.046 secs
00000143 264.41006470 RT_DebugF: ==============================
00000144 264.41146851 RT_DebugF: Type = 4 (BIN)
00000145 264.41165161 RT_DebugF: Dimensions = 3
00000146 264.41183472 RT_DebugF: Dim1 = 500
00000147 264.41198730 RT_DebugF: Dim2 = 20
00000148 264.41217041 RT_DebugF: Dim3 = 10
00000149 264.41235352 RT_DebugF: Nels = 100000
00000150 264.41250610 RT_DebugF: ElSize = 1
00000151 264.41278076 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000152 264.41287231 RT_DebugF: Alloc Time = 0.000 secs (Per element 0.000000 microsecs)
00000153 264.41296387 RT_DebugF:
00000154 264.41296387 RT_DebugF: Check Init
00000155 273.27609253 RT_DebugF: Init END Check1 Passed
00000156 273.27630615 RT_DebugF: Init END Check2 Passed
00000157 273.27651978 RT_DebugF: Init END Check3 Passed
00000158 273.27667236 RT_DebugF: Check Init Time = 8.875 secs (Per element 88.750000 microsecs)
00000159 273.27676392 RT_DebugF: Check Attributes Set/Get
00000160 273.28442383 RT_DebugF: Check Attributes Set/Get = 0.000 secs (Per element 0.000000 microsecs)
00000161 273.28451538 RT_DebugF: Check Set only Time Test on 100000 Nels
00000162 285.04803467 RT_DebugF: Check Set Only Time = 11.766 secs (Per element 117.660217 microsecs)
00000163 285.04812622 RT_DebugF: Check Get only Time Test on 100000 Nels
00000164 293.58193970 RT_DebugF: Check Get Only Time = 8.531 secs (Per element 85.309753 microsecs)
00000165 293.58203125 RT_DebugF: Check Compare Set/Get
00000166 322.62448120 RT_DebugF: Check Compare Set/Get Time = 29.047 secs (Per element 290.470276 microsecs) [Including Data generation]
00000167 322.62457275 RT_DebugF: ALL Checks Done
00000168 322.62460327 RT_DebugF:
00000169 322.62481689 RT_DebugF: Type = 4 (BIN)
00000170 322.62496948 RT_DebugF: Dimensions = 3
00000171 322.62515259 RT_DebugF: Dim1 = 500
00000172 322.62530518 RT_DebugF: Dim2 = 20
00000173 322.62548828 RT_DebugF: Dim3 = 10
00000174 322.62564087 RT_DebugF: Nels = 100000 (Not doubled, Cannot append to multi-dim array)
00000175 322.62582397 RT_DebugF: ElSize = 1
00000176 322.62606812 RT_DebugF: NelMax = 2147483391 ($7FFFFEFF)
00000177 322.62628174 RT_DebugF: Total Time Type=4 (BIN) = 58.219 secs
00000178 322.62649536 RT_DebugF: SCRIPT TOTAL TIME = 322.640 secs



Results on Core Duo Dual Core 2.13GHz, 3GB DDR2, Half full non-system 320 GB SATA2

StainlessS
12th November 2013, 00:37
New version RT_Stats v1.28Beta51 Here:- LINK REMOVED

Changes:-

Changed Beta version in RT_VersionString to show two digits of Beta eg "1.28Beta51".

Several changes to RT_Array type funcs.

*****************************************************
********** RT_ARRAY FUNCTIONS ***********
*****************************************************

RT_ArrayAlloc(string FileName,int "Type"=1,int "Dim1"=0,int "Dim2"=0,int "Dim3"=0,int "StringLenMax"=256)
Creates a file to hold Array elements of type Bool, Int, Float, String, or BIN.
BIN is a BYTE (8 bit) sized Int where only lowest 8 bits of Int are stored in array as an unsigned 8 bit int, upper 24 bits ignored.

Filename, Array Filename, no default.

Type, int, default 1(0 -> 4). 0=Bool, 1=Int, 2 = Float, 3 = String, 4 = BIN.

Dim1, Dim2, Dim3, all Default 0, range 0 or greater. Number of array elements per dimension (max 3 dimensions).
It makes little sense to set either Dim2 or Dim3 to 1 although this will not cause an error condition, just be less efficient,
a 3 dimensional array with all dimensions 1, refers only to a single element but but will take slightly longer to calculate the
linear array offset.

Dim2 and Dim3 fix the number of array dimensions for the lifetime of the array, and also the size of dimensions 2 and 3.

Dim2 Dim3
0 0 Single dimension array
0 >0 Illegal, Throws error condition.
>0 0 Two dimension array, Dim2 fixes size of 2nd dimension.
>0 >0 Three dimension array, Dim2 and Dim3 fix size of 2nd and 3rd dimensions.

Dim1 governs whether array elements are allocated or not. If Dim1=0, then no elements of the array are preallocated and you must call
either RT_ArrayExtend or RT_ArrayAppend (single dimension array ONLY) to use the array. The size of the first dimension can grow whether
it is a 1, 2 or 3 dimension array, the size of the 2nd and 3rd dimensions (if any) are fixed.
With all defaults of 0, would be fixed to a single dimension array with zero allocated elements, must use RT_ArrayAppend to add
elements to the array or RT_ArrayExtend to allocate additional elements and initalize them to zeros
(initialized to zeros, Bool=False,Float=0.0,String="").

With only Dim1 set to eg 1000, would create single dimension array of 1000 elements (0 -> 999), where RT_ArrayAppend and RT_ArrayExtend
can also be used.
With Dim1 and Dim2 greater than zero, would create a two dimensional array, where RT_ArrayAppend can NOT be used, but RT_ArrayExtend
can be used to allocate and add initialized elements to the Dim1 dimension, intialized to zero.
With Dim1, Dim2 and Dim3 greater than zero, would create a three dimensional array, where RT_ArrayAppend can NOT be used, but
RT_ArrayExtend can be used to allocate and add initialized elements to the Dim1 dimension.
Will produce an error if Dim3 is non zero and Dim2 is zero.

StringLenMax, default 256(1 or more). Fixed Maximum string length excluding nul term. Error if string length exceeds.
Only used for Type=3 (string).

Returns total number of elements in array.
All RT_ArrayXXXX() errors produce an error alert.

***
***
***

RT_ArrayGetDim(string FileName,int "Dim"=0)
Returns number of dimensions in array or the size of any 1 of the dimensions.
Filename, Array Filename, no default.
Dim, default 0. (Range 0 -> 3).
0, returns the number of dimensions in the array.
Invalid dimensions will return 0, eg RT_ArrayGetDim(FileName,Dim=2) on single dimension array return 0.
Error if Dim smaller than 0 or greater than 3.

***
***
***

RT_ArrayGetType(string FileName)
Filename, Array Filename, no default.
Returns int, Type as set by RT_ArrayAlloc. 0=Bool, 1=Int, 2 = Float, 3 = String, 4 = BIN.

***
***
***

RT_ArrayGetElSize(string FileName)
Filename, Array Filename, no default.
Returns int, element size, Type 0(bool)=1, 1(int)=4, 2(float)=4, 3(string)=StringLenMax, 4(BIN)=1, as set by RT_ArrayAlloc.

***
***
***

RT_ArrayGetNels(string FileName)
Filename, Array Filename, no default.
Returns int, total number of elements in array as set by RT_ArrayAlloc, or current number of elements if RT_ArrayAppend used to add
elements to end of single dimension array, or RT_ArrayExtend used to increase Dim1 dimension.
For a 3 dimensional array where Dim1=10, Dim2=20,Dim3=30 would return 10*20*30 ie 6000.

***
***
***

RT_ArrayGetDim1Max(string FileName)
Filename, Array Filename, no default.
Returns int, maximum theoretical Dim1 dimension for the current array with current fixed size Dim2 and Dim3 dimensions.
For 1 dimension Array: (maximum +ve integer - header size) / ElSize.
For 2 dimension Array: (maximum +ve integer - header size) / (ElSize * Dim2).
For 3 dimension Array: (maximum +ve integer - header size) / (ElSize * Dim2 * Dim3).

***
***
***

RT_ArrayGetNelMax(string FileName)
Filename, Array Filename, no default.
Returns int, maximum number of elements that could theoretically be stored in current array, taking into account the
current number of dimensions and the size of dimensions 2 and 3.

***
***
***

RT_ArrayGet(string FileName,int ix1,int "ix2",int "ix3")
Returns array element of variable Type as set in RT_ArrayAlloc. Type BIN returns an Int range 0 -> 255.
Filename, Array Filename, no default.
ixl, int, zero relative. 1st subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,1)-1.
ix2, int, zero relative. 2nd subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,2)-1.
Only valid if 2 or 3 dimensional array. For single dimension array, can omit, supply RT_Undefined(), or -1.
ix3, int, zero relative. 3rd subcript of array. Valid range 0 -> RT_ArrayGetDim(FileName,3)-1.
Only valid if 3 dimensional array. For 1 or 2 dimension array, can omit, supply RT_Undefined(), or -1.

***
***
***

RT_ArraySet(string FileName,Var,int ix1,int "ix2",int "ix3")
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc. (NOTE position in arg list changed)
ixl, int, zero relative. 1st subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,1)-1.
ix2, int, zero relative. 2nd subscript of array. Valid range 0 -> RT_ArrayGetDim(FileName,2)-1.
Only valid if 2 or 3 dimensional array. For single dimension array, can omit, supply RT_Undefined(), or -1.
ix3, int, zero relative. 3rd subcript of array. Valid range 0 -> RT_ArrayGetDim(FileName,3)-1.
Only valid if 3 dimensional array. For 1 or 2 dimension array, can omit, supply RT_Undefined(), or -1.
Returns total number of elements in array.

***
***
***

RT_ArrayExtend(string FileName,int "Add"=1)
Extends first dimension of 1, 2 and 3 dimension arrays and initializes additional elements to zero.
(initialized to zeros, Bool=False,Float=0.0,String="").
Filename, Array Filename, no default.
Add, Int default 1. How much to increase size of 1st dimension.
Returns new size of 1st dimension.

***
***
***

RT_ArrayAppend(string FileName,Var)
Adds a variable to end of single dimension array and increments the Nel count.
Filename, Array Filename, no default.
Var, a variable of Type as set in RT_ArrayAlloc.
Returns number of elements in single dimension array.
Error if multi dimensional array.

***
***
***

RT_ArraySetAttrib(string FileName,int ix, Value)
There are 16 available attributes in the Array file header, that can be used for whatever purpose you like,
RT_ArrayAlloc() initializes all Attributes to type Int, 0.
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Value, Int or Float, The value that Attrib(ix) will be set to.
Returns Value. Error if type not of type Int or type Float.

***
***
***

RT_ArrayGetAttrib(string FileName,int ix)
There are 16 available attributes in the Array file header, that can be used for whatever purpose you like,
Filename, Array Filename, no default.
Ix, Attribute array element index range 0 -> 15.
Returns the value of the user set attribute Int or Float (or type Int 0 if not yet set).


Unless suggestions for change, will likely remain as is.

EDIT: Array files are not deleted after use, but can use eg RT_FileDelete(ARRAY) if required.
Can use an existing ARRAY file to store eg plugin path and filenames, or as storage for a library of avs scripts
or many other possible uses.

EDIT: The elements in the currently highest dimension are physically closest to each other in file, so if you say wanted
to eg store a byte value for RGB red channel pixel in an array for a 100 frame clip of dimensions 640x480 then it would
perhaps be best set up with 1st dimension the frame number 0 -> 99, 2nd dimension the Y position 0 ->479,
and the X position 0 -> 639. eg RT_ArrayAlloc(ARRAY,type=4,dim1=100,dim2=480,dim3=640). # Type=4=BIN=8 bit BYTE
Due to filesystem disk caching, this would allow fastest scanning when, for each frame (least often changing), then for each
Y position (next least often changing), then for each X position (most often changing, innermost in nested for/next loops).
Above also most closely matches how pixel data is arranged in memory and so memory cache would also be most
efficiently used.

martin53
14th November 2013, 19:46
StainlessS,
I started to implement the array feature in the AWB script. Please review if this meets the intended usage:

TEMP = RT_GetSystemEnv("TEMP")
NOW = RT_LocalTimeString()
...
GScript(RT_StrReplace(""" #"
#######################################
# 1) Unique Global Variables Initialization
#######################################
#name of the file to hold the RTE array contents
global AWB_Array%%% = TEMP+"\AWB_Array_%%%_"+NOW+".tmp"
#Dim2: [0]=SceneStart, [1]=Red, [2]=Grn, [3]=Blu
RT_ArrayAlloc(AWB_Array%%%, Type=2, Dim1=cRGB.FrameCount, Dim2=4)
#'file destructor'
cRGB.CallCmd("CMD /C del "+AWB_Array%%%, "-3", Hide=true)