View Single Post
Old 21st November 2014, 19:22   #19  |  Link
StainlessS
HeartlessS Usurer
 
StainlessS's Avatar
 
Join Date: Dec 2009
Location: Over the rainbow
Posts: 10,980
Here output of timer, I stopped it early as I have to go out
Code:
00000006    0.47205281      RT_DebugF: RT_Stats Timing Test
00000007    0.47207168      RT_DebugF: Timing 13x5(65) runs on 100000 Frames (Total Frames=6500000)
00000008    26.10106659     RT_DebugF: RT_YankChain       5.122Secs :19524.66FPS :: Basic GetFrame() [ADJUSTMENT]
00000009    496.45959473    RT_DebugF: YPlaneMin         94.071Secs : 1063.02FPS :: ADJUSTED88.950Secs 1124.23FPS
00000010    868.93853760    RT_DebugF: RT_YPlaneMin      74.495Secs : 1342.37FPS :: ADJUSTED69.373Secs 1441.48FPS
00000011    1339.47485352   RT_DebugF: YPlaneMax         94.110Secs : 1062.59FPS :: ADJUSTED88.988Secs 1123.75FPS
00000012    1711.73962402   RT_DebugF: RT_YPlaneMax      74.452Secs : 1343.15FPS :: ADJUSTED69.330Secs 1442.38FPS
00000013    2197.82421875   RT_DebugF: YPlaneMinMaxDif   97.216Secs : 1028.64FPS :: ADJUSTED92.094Secs 1085.85FPS
00000014    2571.29956055   RT_DebugF: RT_YPlaneMinMaxDif74.694Secs : 1338.79FPS :: ADJUSTED69.573Secs 1437.34FPS
00000015    3036.29052734   RT_DebugF: YPlaneMedian      93.009Secs : 1075.16FPS :: ADJUSTED87.888Secs 1137.82FPS
00000016    3407.98608398   RT_DebugF: RT_YPlaneMedian   74.338Secs : 1345.20FPS :: ADJUSTED69.217Secs 1444.74FPS
00000017    3551.94287109   RT_DebugF: AverageLuma       28.930Secs : 3456.65FPS :: ADJUSTED23.808Secs 4200.26FPS
00000018    3648.14013672   RT_DebugF: RT_AverageLuma    19.239Secs : 5197.90FPS :: ADJUSTED14.117Secs 7083.76FPS
The figures are adjusted by subtracting time taken for basic GetFrame ie removing timing for sourcefilter, script etc and so are timing only
the functions themselves.
Does five timings on each routine and throws away fastest and slowst times then averages remaining 3.

The non AverageLuma functions are slower due to them using a count array rather than single accumulator.


Here the script:
Code:
TITLE="RT_Stats Timing Test"
RUNS   = 5          # Number of runs of each function, slowest and fastest discarded, timed on average of remainder
NFRAMES=100000      # Number of Frames to use from Source Clip

#AVISource("D:\avs\TEST.avi")
Colorbars(pixel_type="YV12")

Trim(0,NFRAMES-1).KillAudio()


# Function names for Display only
Names="
    RT_YankChain
    YPlaneMin
    RT_YPlaneMin
    YPlaneMax
    RT_YPlaneMax
    YPlaneMinMaxDif
    RT_YPlaneMinMaxDif
    YPlaneMedian
    RT_YPlaneMedian
    AverageLuma
    RT_AverageLuma
    Avisynth_ALL
    RT_Avisynth_ALL
    RT_ALL
"

TESTS=13    # Total number of test incl RT_Yankchain # EDIT: Should read 'not including RT_Yankchain'

GSCript("""
    Function Test_00(clip c){c for(i=0,framecount-1){current_frame=i RT_YankChain(Last)} return c}
    Function Test_01(clip c){c for(i=0,framecount-1){current_frame=i YPlaneMin(Last)} return c}
    Function Test_02(clip c){c for(i=0,framecount-1){current_frame=i RT_YPlaneMin(Last)} return c}
    Function Test_03(clip c){c for(i=0,framecount-1){current_frame=i YPlaneMax(Last)} return c}
    Function Test_04(clip c){c for(i=0,framecount-1){current_frame=i RT_YPlaneMax(Last)} return c}
    Function Test_05(clip c){c for(i=0,framecount-1){current_frame=i YPlaneMinMaxDifference(Last)} return c}
    Function Test_06(clip c){c for(i=0,framecount-1){current_frame=i RT_YPlaneMinMaxDifference(Last)} return c}
    Function Test_07(clip c){c for(i=0,framecount-1){current_frame=i YPlaneMedian(Last)} return c}
    Function Test_08(clip c){c for(i=0,framecount-1){current_frame=i RT_YPlaneMedian(Last)} return c}
    Function Test_09(clip c){c for(i=0,framecount-1){current_frame=i AverageLuma(Last)} return c}
    Function Test_10(clip c){c for(i=0,framecount-1){current_frame=i RT_AverageLuma(Last)} return c}
    Function Test_11(clip c){c for(i=0,framecount-1){current_frame=i \
            YPlaneMin(Last) YPlaneMax(Last) YPlaneMinMaxDifference(Last) YPlaneMedian(Last) AverageLuma(Last)} return c}
    Function Test_12(clip c){c for(i=0,framecount-1){current_frame=i RT_YStats(Last,flgs=$1F)} return c}        # As Test_11
    Function Test_13(clip c){c for(i=0,framecount-1){current_frame=i RT_YStats(Last,flgs=$7F,lo=0,hi=255)} return c}
    # As Test_12 + RT_Stdev+RT_YInRange
    Assert(RUNS>=3,"RUNS MUST be at least 3")
    Frames=FrameCount()
    YankAve=0.0                                             # Adjustment, will be subtracted from timings of non YankChain fns
    PStr=RT_String("%s\nTiming %dx%d(%d) runs on %d Frames (Total Frames=%d)",TITLE,TESTS,RUNS,TESTS*RUNS,NFRAMES,TESTS*RUNS*NFRAMES)
    RT_debugF("%s",Pstr)
    TStart=RT_TimerHP()                                     # Total Runtime Start
    For(Test=0,TESTS) {
        EStr="Test_"+RT_NumberString(Test,10,2)+"()"        # Func to EVALuate
        Times=""
        for(Run=1,RUNS) {
            s=RT_TimerHP()  Eval(EStr)  e=RT_TimerHP()  t = e-s     # Time Function
            Times=RT_TxtAddStr(Times,String(t))
#           RT_DebugF("%s %d] S=%6.2f E=%6.2f Time=%6.2f",EStr,Run,s,e,t)
        }
        Times=RT_TxtSort(Times,9)                               # Sort Float strings ascending
        Ave = 0.0                                               #
        for(i=1,RUNS-2) {Ave=Ave+Value(RT_TxtGetLine(Times,i))} # excluding slowest and fastest run
        Ave=Ave / Float(RUNS-2)                                 # Get Average Time, discarding slowest and fastest run
        FPS=Frames / Ave                                        # Ave FPS
        Title = RT_StrReplaceMulti(RT_TxtGetLine(Names,Line=Test+1)," "+Chr(10)+Chr(9),Chr(10)+Chr(10)) # Remove any SPACE + TAB
        Title = RT_StrPad(Title,18)                                                                     # Align
        OStr=RT_String("%s%6.3fSecs :%8.2fFPS",Title,ave,FPS)
        if(Test==0) {
            YankAve=Ave                                         # Average of basic GetFrame() ONLY time
            OStr=OStr+" :: Basic GetFrame() [ADJUSTMENT]"
        } else {
            AdjustedTime = Ave-YankAve
            AdjustedFPS = Frames / AdjustedTime
            OStr=RT_String("%s :: ADJUSTED%6.3fSecs %7.2fFPS",OStr,AdjustedTime,AdjustedFPS)
        }
        RT_DebugF("%s",OStr)
        PStr=RT_TxtAddStr(PStr,OStr)
    }
    TEnd=RT_TimerHP()                                               # Total Runtime End
    TTime=RT_String("Total Runtime = %6.2fMins",(TEnd-TStart)/60.0)
    RT_DebugF("%s",TTime)
    PStr=RT_TxtAddStr(PStr,TTime)
#   RT_DebugF("%s",PStr)
    SStr=RT_StrReplace(PStr,Chr(10),"\n")                       # Convert Chr(10) to '\n' for correct Subtitle display
    SubTitle(Sstr,font="Courier New",size=16,lsp=0)
""")
EDIT: The 'Tight Loop' in question from RT_AverageLuma on Planar Y
Code:
for(y=0 ; y < hh; y += ystep) {
    for (x=ww ; --x>=0 ; ) {
        sum += srcp[x];
    }
    if(sum & 0x80000000) {acc += sum;sum=0;} // avoid overflow (big frame support, not available in AverageLuma)
    srcp += ystride;
}
__________________
I sometimes post sober.
StainlessS@MediaFire ::: AND/OR ::: StainlessS@SendSpace

"Some infinities are bigger than other infinities", but how many of them are infinitely bigger ???

Last edited by StainlessS; 22nd November 2014 at 17:52.
StainlessS is offline   Reply With Quote