byte-physics / igortest

Igor Pro Universal Testing Framework
https://docs.byte-physics.de/igor-unit-testing-framework/
BSD 3-Clause "New" or "Revised" License
7 stars 2 forks source link

Clearing of info wave is slow #472

Closed MichaelHuth closed 4 weeks ago

MichaelHuth commented 1 month ago

https://github.com/byte-physics/igortest/blame/d557db885f2077bb1998cf9ef938477881c44775/procedures/igortest-reporting.ipf#L271

Some test profiling for UTF_Labnotebook.ipf from MIES shows that this line uses 15% of all function time for the whole test suite.

@Garados007 Is the clear really necessary or would setting the vector length suffice ?

t-b commented 1 month ago
Function Dostuff()

    variable ref, i, numRuns = 1000

    Make/FREE/T/N=1e4 wv

    ref = stopmstimer(-2)
    for(i = 0; i < numRuns; i += 1)
        wv = ""
    endfor
    printf "Time %15s: %f mus\r", "main", (stopmstimer(-2) - ref) / numRuns

    ref = stopmstimer(-2)
    for(i = 0; i < numRuns; i += 1)
        Multithread wv = ""
    endfor
    printf "Time %15s: %f mus\r", "multithread", (stopmstimer(-2) - ref) / numRuns
End

Using IP9 56685 gives

•dostuff()
  Time            main: 2151.483200 mus
  Time     multithread: 565.863500 mus

Instead of only changing the vector length it might be enough to only blank out the filled entries.

Garados007 commented 1 month ago

Is the clear really necessary or would setting the vector length suffice ?

As far as I know there is no need to clean up the info wave. Only the vector length tells me how many entries are contained. Clearing of the wave is only done to make debugging easier (it's easier to visually grasp how many elements are contained) and to prevent the use of old elements in case of bugs.

There is an edge case for which the clean up can be useful but I need some tests. Lets say, the info wave contains a string with several GB content (or many smaller ones). Keeping this one forever will result in a high memory usage, which can be removed if we just clear the wave after usage.

t-b commented 1 month ago

@Garados007 Okay so let's not clear the info wave then.