FreeRDP
metrics.c
1 
20 #include <freerdp/config.h>
21 
22 #include "rdp.h"
23 
24 double metrics_write_bytes(rdpMetrics* metrics, UINT32 UncompressedBytes, UINT32 CompressedBytes)
25 {
26  double CompressionRatio = 0.0;
27 
28  metrics->TotalUncompressedBytes += UncompressedBytes;
29  metrics->TotalCompressedBytes += CompressedBytes;
30 
31  if (UncompressedBytes != 0)
32  CompressionRatio = ((double)CompressedBytes) / ((double)UncompressedBytes);
33  if (metrics->TotalUncompressedBytes != 0)
34  metrics->TotalCompressionRatio =
35  ((double)metrics->TotalCompressedBytes) / ((double)metrics->TotalUncompressedBytes);
36 
37  return CompressionRatio;
38 }
39 
40 rdpMetrics* metrics_new(rdpContext* context)
41 {
42  rdpMetrics* metrics = NULL;
43 
44  metrics = (rdpMetrics*)calloc(1, sizeof(rdpMetrics));
45 
46  if (metrics)
47  {
48  metrics->context = context;
49  }
50 
51  return metrics;
52 }
53 
54 void metrics_free(rdpMetrics* metrics)
55 {
56  free(metrics);
57 }