- [PYTHON] ASCII generator
可播彩六
Original readme could be found at https://github.com/vietnh1009/ASCII-generator.
This repository is a fork of the original repository, featuring stream-to-stream conversion to ASCII art.
- Implemented stream-to-stream conversion.
- Still supports file-to-file conversion.
- Optimized performance by splitting functions into separate threads.
- Enhanced screen capture speed using
mss
. - Replaced nested loops with
np.mean
for improved efficiency.
Before threading, the typical fps is 7-8 (4K, stream-to-stream, file-to-file not supported yet)
Separating major functions into separate threads with a shared queue of size 1 significantly improves performance.
After splitting the functions into separate threads, the typical fps is 9-10 (4K, file-to-file)
The nested loop version (
main
) takes approximately 0.09 seconds, serving as the program's bottleneck. Note that thescreenshot
time here is inaccurately measured, as it includes the wait time for putting the image into the queue while themain
function continues to process the queue.
Overall performance (fps) is now determined by the most time-consuming thread, which we will split into separate threads.
The screenshot time is reduced from 0.1
to 0.04
seconds, increasing fps by 5-10 at 4K resolution.
After replacing the nested loops with
np.mean
, the typical fps is 17-20 (4K, file-to-file)
The time distribution is now more balanced across each component.
Splitting
mean
andtext
decreases bottleneck time to 0.06 seconds, yielding a theoretical performance of 16.67 fps and an actual performance of 17-20 fps. (4K, file-to-file)
Move time-consuming functions to separate threads to further improve performance.
- Split
mean
andtext
will increase little delay but improve performance.