On Tue, Dec 31, 2013 at 03:57:40AM +0100, noselasd(a)fiane.dyndns.org wrote:
see attached patch for an example
(it may now truncate the hex dumps at a byte boundary vs at a nibble
when using snprintf if the hex exceeds sizeof(hexd_buff) though)
nice speed-up in deed. I will add a regression for the new truncation.
We seldomly (read never) deal with messages of 4k.
The below code goes from:
real 0m3.233s
user 0m3.212s
sys 0m0.000s
to:
real 0m0.085s
user 0m0.084s
sys 0m0.000s
#include <stdio.h>
#include <stdlib.h>
#include <osmocom/core/utils.h>
int main(int argc, char **argv)
{
static const int lengths[] = { 23, 1000, 52 };
char buf[4096];
int i;
for (i = 0; i < 30000; ++i) {
char *res = osmo_hexdump(buf, lengths[i & 3]);
}
}