Does anyone know how to add MCCP compression stats to a statistics command? I just used a patch to install the MCCP, though I had to do it manually, no autopatching such a heavily modified code.
I'm looking to see the total bytes compressed out and in if possible, and the compression ratio. Anyone know if this information is stored somewhere already, or if it has to be added from scratch?
Well I know MUSHclient shows that data, but I don't know any snippets for the actual MUD.
I think the MCCP snippets just compress the data. I'm pretty sure they have the before/after sizes there (you need them to compress/send, after all), but I imagine that you'll have to compute the ratios and store it all manually.
This is the code that I use for my compression stats, feel free to take and modify:
send_to_char("Compression Info:\n\r", ch);
send_to_char("Compression: &B[&w", ch);
if (IS_MXP(ch))
send_to_char(MXPTAG("mxptoggle compress"), ch);
if (ch->desc->compressing)
send_to_char("ON ", ch);
else
{
send_to_char("OFF", ch);
}
if (IS_MXP(ch))
send_to_char(MXPTAG("/mxptoggle"), ch);
send_to_char("&B]&D\n\r", ch);
if (ch->desc->out_compress
&& ch->desc->out_compress->total_in)
ch_printf(ch,
"Total size of input compressed: &B[&w%d&B]&D\n\r",
ch->desc->out_compress->total_in);
if (ch->desc->out_compress
&& ch->desc->out_compress->total_out)
ch_printf(ch,
"Total size of output compressed: &B[&w%d&B]&D\n\r",
ch->desc->out_compress->total_out);
if (ch->desc->out_compress && ch->desc->out_compress->total_in
&& ch->desc->out_compress->total_out)
ch_printf(ch,
"Current compression ratio: &B[&w%.2f%&B]&D&D\n\r",
(float) ((float) ch->desc->out_compress->
total_out /
(float) ch->desc->out_compress->
total_in * 100));
I also know that the casting is terrible, I just never got around to fixing it... love that pedantic flag.
You actually don't need to cast both operands of a multiplication/division to float/double to get double precision. If the compiler detects that just one of them is floating point, it'll use fp-math. I tend to cast both as well, but it can sometimes save space.
Also, C++ lets you use the (IMO, at least) nicer format of casting: float(foo) instead of (float) foo. (Well, technically this isn't a cast, but it has the same effects.) Not sure if you're using C++ or not; I think I remember something about you moving to it a while ago. :)