Whats the fastest way to write to the console [Answered]
This is what i currently have and it still caps at arround 30fps with 283x480 characters
Now it caps and i cant figure out a more efficient way of doing this
38 Replies
only 30fps really?
hmm my code is a little different but has +100fps easely
<:PES_Think:639363477458255874>
what fontsize you got
normal font size but full screen console
im also using the new terminal but ik not sure ig thats any faster
y, im a fontsize of 1
..
you should probably not call getstdhandle every time you write
you arent allocating a new char info array every write are you?
no no its all preallocated
bcuz allocating is slow, you should reuse the array
good
uhh
are you sure its writing to the console thats slow and not something else?
well, its the only thing the programm does, everything needed is predone before
<:PES_Think:639363477458255874>
personally
i use CreateConsoleScreenBuffer and SetConsoleActiveScreenBuffer so replace the stdhandle with my own console buffer
and then write to that, idk if that changes the speed
is there a thread sleep in your code or something?
how do you measure the fps
nope
i keep count of the frames and divide by the ms/1000
with a stopwatch?
y
it's what it's and it's slow
i do think it should be at least 60fps though
well im writing about 4.075.200 characters to the buffer every second
well
thats a lot to ask
i guess
ik
write your own "console host" and render in there
im using the windows 10 terminal is there a performance
<:PES_SadShrug:646092743378206760>
its "easy" to write your colors to a buffer and then copy that buffer to a HDC buffer to draw that but WinGDI is getting slower every windows update
bcuz the api is ancient
guess thats the only way
...
or spend a month learning directx and win32 to draw at 10 000 fps on the gpu
prob gonna take me more than a month using
maybe a bitmapsource in wpf is fast and easy enough didnt i do that before
BitmapSource Class (System.Windows.Media.Imaging)
Represents a single, constant set of pixels at a certain size and resolution.
ah here easy
dont create a bitmap each frame, you can just write to it again
or if you want to stay in the console. maybe just a lower resolution then
well, the challenge is to get it to work in the console, but since i cant exceed 30 frames and i dont wanna destroy my mental health learning directx
y either that or cap fps
meaning skipping 1 frame if the framerate is over 30 fps
which is probably the only solution viable at this point
🤷♂️
maybe try this
you also dont have to do that every write
just once
1s let me try
also get the width and height of the console just once at the start and ignore resizing
did some testing,
getting the handle outside with the width and height improved not alot maybe half a frame
at the start it spiked 37fps but later went down to 33,4 fps where it stayed for the whole video
+ new terminal
guess its just gonna get down to me capping the frames of the video
nontheless ty for the suggestions ❤️
✅ This post has been marked as answered!