codeblocks_sf icon indicating copy to clipboard operation
codeblocks_sf copied to clipboard

Speedup memorydump

Open MicroSourceCode opened this issue 3 years ago • 12 comments

Replacing the m_pText->clear() function with the replace function, it works faster. Replace 2 appendText calls with one writeText call, speed up when outputting bytes greater than 512, writeText is faster.

MicroSourceCode avatar Mar 06 '21 13:03 MicroSourceCode

Can you provide any measurements before/after? You can use the wxStopWatch class.

obfuscated avatar Mar 06 '21 15:03 obfuscated

Ok, I will send later

 

Суббота, 6 марта 2021, 18:08 +03:00 от obfuscated [email protected]:     Can you provide any measurements before/after? You can use the wxStopWatch class. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .     -- Владимир Макарычев  

MicroSourceCode avatar Mar 06 '21 19:03 MicroSourceCode

Result next: Time func REPLACE: 0.000060543 Time func CLEAR: 0.000040974 Time func CHANGEVALUE: 0.000038363   ChangeValue has the best result. I suggest replacing Clear() with ChangeValue (""); wxStopWatch did not work, tests were carried out using the hrono library. To be continued... C    

Ok, I will send later

 

Суббота, 6 марта 2021, 18:08 +03:00 от obfuscated < [email protected] >:     Can you provide any measurements before/after? You can use the wxStopWatch class. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub , or unsubscribe .     -- Владимир Макарычев       -- Владимир Макарычев  

MicroSourceCode avatar Mar 07 '21 08:03 MicroSourceCode

And the units are?

obfuscated avatar Mar 07 '21 09:03 obfuscated

In seconds, but I doubt it. WriteText is faster because it does not move the cursor to the end. WriteText: 0.000029586 Single line output ExpandText: 0.000030745 Single line output Overall if block speed: if (m_ByteCounter != 0 && m_ByteCounter % 16 == 0) old: 0.000050524 new 0.000031741

MicroSourceCode avatar Mar 07 '21 12:03 MicroSourceCode

If these are in seconds, this means that this optimization doesn't matter in the real world. Are you able to see visible difference between the two implementations?

obfuscated avatar Mar 07 '21 12:03 obfuscated

There is no particular difference, but replacing AppendText with WriteText fixed the wxwidget 3.0.4 memory leak on my system. The debugger has stopped slowing down.

MicroSourceCode avatar Mar 07 '21 16:03 MicroSourceCode

I will try to test the program on the wxwidget version 3.0.5, maybe the error has already been fixed.

MicroSourceCode avatar Mar 07 '21 17:03 MicroSourceCode

Still, there is a gain in speed, all of the above referred to one line of output, except for the Replace and ChangeValue functions, but there are much more lines, so I see an increase in performance.

MicroSourceCode avatar Mar 08 '21 16:03 MicroSourceCode

Can you measure it? I guess you can use wxStopWatch around the callers of AddHexByte. But if this change is improving performance then a change in the API would lead to a bigger change.

obfuscated avatar Mar 08 '21 16:03 obfuscated

I did some research and I figured out what was going on. inserted the call to start the timer into the Begin function and the time display function into the End function. The Begin function starts wxTextCtrl at the beginning of the fill cycle, and the End function runs after it has filled. My changes give a decrease in time from 18 ms to 12 ms, but this is not particularly important. The program slows down dramatically when using the AppendText function, I pressed the Go button in the Memory window thirty times and wxTextCtrl slowed down dramatically, its running time increased from 1 second to 4 seconds when outputting 4096 bytes, but the program output time remained the same 12-18 milliseconds! The WriteText function bypassed a bug in wxWidget 3.0.4, the same behavior observed when using wxWidget 3.0.6.

MicroSourceCode avatar Mar 09 '21 19:03 MicroSourceCode

I compiled wxwidget 3.0.6 with only gtk2 support, performance improved, the AppendText function began to work much better, but the fill cycle time began to gradually increase from 12 to 100 ms, this indicates that gtk3 uses a buffer for its elements and only then outputs data.

MicroSourceCode avatar Mar 10 '21 08:03 MicroSourceCode