On Tue, 17 Nov 2015 15:40:36 -0800 (PST)
anatoly techtonik <
tech...@gmail.com> wrote:
> We have a dispute if handling Windows console should be done the
> same way as Linux terminal. I feel that Linux terminal is slower
> (Gnome terminal in particular), but I can prove that. Are there any
> tests on Go that can test this cross-platform and show FPS.
>
> For Windows there is
http://www.pouet.net/prod.php?which=18381 that
> runs at about 60 FPS in 80x50 window and has some C++ code. What
> would be the equivalent for Linux?
I'm not sure about Windows console but "on Linux" (it's a strange term
but oh well) "the console" is a way more moot term or, rather, a term
which stands for a broader concept [1]. In short, back in the olden
days, "the console" stood for a hardware terminal connected to a host
machine (which actually run programs) via some sort of serial
connection (either direct RS-232 cable or modem etc). To not reinvent
the wheel, the Linux kernel, while supporting "true" hardware terminals,
does support two other concepts both of which *emulate* hardware
terminals to some degree:
1) Virtual terminals (VTs) [2]: are those text windows you see on an x86
machine when physically working with it "in text mode" (that is,
without graphical display provided by X Window System).
2) Pseudo terminals (PTYs) [3]: a completely virtualized solution which
provides terminal facilities to program which are not interfacing
to any hardware.
This one is the most tricky, and is used by several popular kinds
of software:
* Terminal emulators for X Window System;
* SSH client sessions;
* Software terminal multiplexers (screen, tmux).
Your GNOME Terminal is in fact not "a console" in the full sense of
this word but rather a "terminal emulator for X Window System".
And it uses the same protocol to interact with the programs it runs
a hardware terminal would use or a VT.
As you could have guessed, when you measure how GNOME Terminal renders
something, you should first try to understand what exactly you're
measuring. This might be the speed at which its code interfacing X
performs or this might be the speed at which it talks to the PTY
subsystem or it might be the speed of the PTY subsystem or it might be
the speed of the library used to talk to PTY or whatever.
As to low-level code for talking to the host's terminal subsystem, you
might look at the ncurses package (a ubiquitous solution on POSIX
systems to write "full-screen" text programs, written in C) or the
termbox-go package for a pure Go solution (and cross-platform, FWIW).
1.
https://en.wikipedia.org/wiki/Computer_terminal#Text_terminals
2.
https://en.wikipedia.org/wiki/Virtual_console
3.
https://en.wikipedia.org/wiki/Pseudoterminal