[PATCH v2 1/4] Cygwin: console: Add workaround for broken IL/DL in xterm mode.
Takashi Yano
takashi.yano@nifty.ne.jp
Sun Mar 1 06:33:00 GMT 2020
On Fri, 28 Feb 2020 22:00:40 +0100
Hans-Bernhard Bröker wrote:
> // simple helper class to accumulate output in a buffer
> // and send that to the console on request:
> static class
> {
> private:
> unsigned char buf[WPBUF_LEN];
> int ixput;
>
> public:
> inline void put(unsigned char x)
> {
> if (ixput < WPBUF_LEN)
> {
> buf[ixput++] = x;
> }
> };
> inline void empty() { ixput = 0; };
> inline void sendOut(HANDLE &handle, DWORD *wn) {
> WriteConsoleA (handle, buf, ixput, wn, 0);
> };
> } wpbuf;
I agree your solution is more C++-like and smart.
However, from the view point of performance, just inline
static function is better. Attached code measures the
performance of access speed for wpbuf.
I compiled it by g++ 7.4.0 with -O2 option.
The result is as follows.
Total1: 2.315627 second
Total2: 1.588511 second
Total3: 1.571572 second
Class implementation is slow 40% than inline or macro.
So, IMHO, inline static function is the best.
--
Takashi Yano <takashi.yano@nifty.ne.jp>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: wpbuf-bench.cc
Type: text/x-c++src
Size: 1474 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20200301/4340a048/attachment.bin>
More information about the Cygwin-patches
mailing list