]> git.sesse.net Git - rdpsrv/blob - Xserver/programs/Xserver/hw/vnc/stats.c
Support RDP5 logon packets.
[rdpsrv] / Xserver / programs / Xserver / hw / vnc / stats.c
1 /*
2  * stats.c
3  */
4
5 /*
6  *  Copyright (C) 2002 RealVNC Ltd.
7  *  Copyright (C) 1999 AT&T Laboratories Cambridge.  All Rights Reserved.
8  *
9  *  This is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 2 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This software is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this software; if not, write to the Free Software
21  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
22  *  USA.
23  */
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include "rfb.h"
28
29 static char* encNames[] = {
30     "raw", "copyRect", "RRE", "[encoding 3]", "CoRRE", "hextile",
31     "[encoding 6]", "[encoding 7]", "[encoding 8]", "[encoding 9]",
32     "[encoding 10]", "[encoding 11]", "[encoding 12]", "[encoding 13]",
33     "[encoding 14]", "[encoding 15]", "ZRLE", "[encoding 17]",
34     "[encoding 18]", "[encoding 19]", "[encoding 20]"
35 };
36
37
38 void
39 rfbResetStats(rfbClientPtr cl)
40 {
41     int i;
42     for (i = 0; i < MAX_ENCODINGS; i++) {
43         cl->rfbBytesSent[i] = 0;
44         cl->rfbRectanglesSent[i] = 0;
45     }
46     cl->rfbFramebufferUpdateMessagesSent = 0;
47     cl->rfbRawBytesEquivalent = 0;
48     cl->rfbKeyEventsRcvd = 0;
49     cl->rfbPointerEventsRcvd = 0;
50 }
51
52 void
53 rfbPrintStats(rfbClientPtr cl)
54 {
55     int i;
56     int totalRectanglesSent = 0;
57     int totalBytesSent = 0;
58
59     rfbLog("Statistics:\n");
60
61     if ((cl->rfbKeyEventsRcvd != 0) || (cl->rfbPointerEventsRcvd != 0))
62         rfbLog("  key events received %d, pointer events %d\n",
63                 cl->rfbKeyEventsRcvd, cl->rfbPointerEventsRcvd);
64
65     for (i = 0; i < MAX_ENCODINGS; i++) {
66         totalRectanglesSent += cl->rfbRectanglesSent[i];
67         totalBytesSent += cl->rfbBytesSent[i];
68     }
69
70     rfbLog("  framebuffer updates %d, rectangles %d, bytes %d\n",
71             cl->rfbFramebufferUpdateMessagesSent, totalRectanglesSent,
72             totalBytesSent);
73
74     for (i = 0; i < MAX_ENCODINGS; i++) {
75         if (cl->rfbRectanglesSent[i] != 0)
76             rfbLog("    %s rectangles %d, bytes %d\n",
77                    encNames[i], cl->rfbRectanglesSent[i], cl->rfbBytesSent[i]);
78     }
79
80     if ((totalBytesSent - cl->rfbBytesSent[rfbEncodingCopyRect]) != 0) {
81         rfbLog("  raw bytes equivalent %d, compression ratio %f\n",
82                 cl->rfbRawBytesEquivalent,
83                 (double)cl->rfbRawBytesEquivalent
84                 / (double)(totalBytesSent
85                            - cl->rfbBytesSent[rfbEncodingCopyRect]));
86     }
87 }