Looks for smaps member using a gperf table instead of using

bsearch.
Brings a 25% boost.
This commit is contained in:
Benoît Dejean
2009-05-03 16:40:13 +02:00
parent 15abcdbbf2
commit d99a29d217
4 changed files with 218 additions and 42 deletions

View File

@@ -0,0 +1,21 @@
%language=ANSI-C
%includes
%struct-type
%readonly-tables
%pic
%define lookup-function-name _glibtop_find_smap
%compare-lengths
%{
#include "glibtop_private.h"
#include <glibtop/procmap.h>
#include <stddef.h>
#define SMAP_OFFSET(MEMBER) offsetof(glibtop_map_entry, MEMBER)
%}
struct smap_value { int name; ptrdiff_t offset; };
%%
Private_Clean:, SMAP_OFFSET(private_clean)
Private_Dirty:, SMAP_OFFSET(private_dirty)
Rss:, SMAP_OFFSET(rss)
Shared_Clean:, SMAP_OFFSET(shared_clean)
Shared_Dirty:, SMAP_OFFSET(shared_dirty)
Size:, SMAP_OFFSET(size)