Questions tagged [gperf]

GNU gperf is a perfect hash function generator. For a given list of strings, it produces a hash function and hash table, in form of C or C++ code, for looking up a value depending on the input string. The hash function is perfect, which means that the hash table has no collisions, and the hash table lookup needs a single string comparison only.

GNU gperf is a perfect hash function generator. For a given list of strings, it produces a hash function and hash table, in form of C or C++ code, for looking up a value depending on the input string. The hash function is perfect, which means that the hash table has no collisions, and the hash table lookup needs a single string comparison only. more...

21 questions
7
votes
2 answers

Perfect hash function?

While reading the pigeonhole principle on Wikipedia, I come across - "collisions are inevitable in a hash table because the number of possible keys exceeds the number of indices in the array. No hashing algorithm, no matter how clever, can avoid…
user138645
  • 772
  • 1
  • 7
  • 18
4
votes
1 answer

Determine which signal caused EINTR?

I am running an epoll loop and sometimes my call to epoll_wait returns -1 with errno set to EINTR. Sometimes, I want this to end the epoll loop, like in the case of SIGTERM or SIGINT. But I have this code compiled with the -pg flag, so periodic…
Brian Schlenker
  • 4,966
  • 6
  • 31
  • 44
3
votes
1 answer

Is there a way to profile a MPI program with detailed cache/CPU efficiency information?

OS: Ubuntu 18.04 Question: How to profile a multi-process program? I usually use GNU perf tool to profile a program as follows: perf stat -d ./main [args], and this command will return a detailed performance counter as follows: 47,455.09…
3
votes
1 answer

Can gperf accept keywords defined by macros?

I would like something like the following gperf input file: %{ #include // the contents of which contain // #define KEYWORD1_MACRO "keyword1" // #define KEYWORD2_MACRO "keyword2" %} %% KEYWORD1_MACRO KEYWORD2_MACRO %% Unfortunately,…
gavinbeatty
  • 319
  • 2
  • 10
2
votes
1 answer

Why am I getting an undefined reference in this C++ code?

I am trying to learn how to use the gperf library for perfect hashing on an Ubuntu 14.04 computer. I am getting compiler errors. Can someone help me out with this? gperf is a library which when provided with a set of static keys to hash like for…
smilingbuddha
  • 14,334
  • 33
  • 112
  • 189
2
votes
1 answer

Attempting to install python library snudown, get gperf error

C:\Users\Nick\Documents\prog\python\snudown>python setup.py install running install running bdist_egg running egg_info writing snudown.egg-info\PKG-INFO writing top-level names to snudown.egg-info\top_level.txt writing dependency_links to…
nicolashahn
  • 539
  • 7
  • 19
2
votes
2 answers

Profile C code execution percentage (line-by-line annotation)

I need to profile a couple of C codes and get an annotated file with percentage of exeuction time taken by each line or atleast each block(while/if-else/for-functions) etc. So far I have looked into valgrind(callgrind) and gperf and some other…
jav321
  • 151
  • 2
  • 11
2
votes
2 answers

How to use gperf to create hash for a range of values?

I have range of hex numbers like these 0xabcd**** 0xabdc**89 0x****abcd 0xde****ab # 50 or so more entries like these # where * is any hex number I need a hash a function that will accept a 4byte value and generate Y/N answer for membership. I…
user2708149
  • 475
  • 4
  • 7
1
vote
1 answer

How to add gperf to windows 7 classpath (and have it recognized in DOS)

I'm trying to add GPERF to my classpath in order to build some Titanium 1.8+ modules. I've installed GPERF from http://gnuwin32.sourceforge.net and assigned the path to my CLASSPATH and PATH variables, but eclipse / dos isn't picking it up. Any…
Leonidas
  • 2,110
  • 4
  • 20
  • 31
1
vote
2 answers

gperftools not installing -lprofiler on Mac after installing it with brew

Recently I wanted to profile my cpp code and came across gperftool, but there aren't really clear instructions on how to use it with Mac. So far I have run brew install gperftools and wanted to compile my simple cpp file which just outputs "Hello…
Orif Milod
  • 465
  • 1
  • 7
  • 17
1
vote
1 answer

Beginner: How do I actually use gperf? It just hangs every time I run it

I am very new to coding, currently taking Harvard's CS50x class online. The extent of my familiarity with code, languages, and environments is what they've taught me so far in C. With vague guidance from other questions on this site, I've taken…
CJS
  • 23
  • 3
1
vote
1 answer

Find minimal perfect hash function with gperf

I found gperf to be suitable for my project and are now looking for a way to optimize the size of the generated table. As the switches -i and -j influence the length of the table deterministically, I wrote a small script iterating over those values,…
walderich
  • 500
  • 1
  • 9
  • 24
1
vote
0 answers

Google Cpu profiler

I want to try google cpu profiler to analyze hotspots on a C project as an alternative to gprof so to find any differencies because i am not convinced about the accuracy gprof provides, but as i am now introducing myself to these tools i am…
grenov4
  • 11
  • 1
0
votes
0 answers

Implementation of exceptions in C++

Do gcc and clang/LLVM generate a hash table with a perfect hash function, keyed by all return addresses from exception throwing functions? Do they use the same algorithm (to generate the hash function) as gperf?
WaltK
  • 724
  • 4
  • 13
0
votes
1 answer

How to use null bytes in gperf?

The gperf info pages claims that if you specify -l then The keywords in the input file may contain NUL bytes, written in string syntax as \000 or \x00, and the code generated by gperf will treat NUL like any other byte However when I run this…
Thomas Johnson
  • 10,776
  • 18
  • 60
  • 98
1
2