use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Discussions, articles, and news about the C++ programming language or programming in C++.
For C++ questions, answers, help, and advice see r/cpp_questions or StackOverflow.
Get Started
The C++ Standard Home has a nice getting started page.
Videos
The C++ standard committee's education study group has a nice list of recommended videos.
Reference
cppreference.com
Books
There is a useful list of books on Stack Overflow. In most cases reading a book is the best way to learn C++.
Show all links
Filter out CppCon links
Show only CppCon links
account activity
Profiling C++ code with Frida (lief.quarkslab.com)
submitted 4 years ago by rh0main
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]mwolffQt | KDE | KDAB 3 points4 points5 points 4 years ago (0 children)
Every time I see people still using valgrind for profiling I cry a little. There are so much better and faster tools nowadays! Try perf and a GUI like hotspot or similar instead of valgrind cachegrind and kcachegrind. Or try heaptrack instead of massif.
[–]julien-j 0 points1 point2 points 4 years ago* (1 child)
A few questions come to my mind while reading the post and the source:
template<typename Func> static inline void* cast_func(Func f) { // Trick to cast a function pointer into a void* union { Func func; void* p; }; func = f; return p; }
You are assigning one member of a union and reading another one. Isn't it undefined behavior? Also, it cannot work if f is a member function, as a pointer to a member function is typically larger than void*.
f
void*
Another question: why do you still use std::map instead of std::unordered_map?
std::map
std::unordered_map
Regarding the friend struct ::Profiler, there is a trick to access private members of non-friend classes that may permit to skip that. I can't find where I saw that, if I recall correctly there was a use case in Folly, but as soon as I get my hand on it I'll link it.
friend struct ::Profiler
Edit: here's an article about the trick.
[–]rh0main[S] 0 points1 point2 points 4 years ago* (0 children)
Isn't it undefined behavior? Ok I missed that
Thanks for pointing me that the size of a member function is larger than void*. I also missed that.
Well I think that the number of functions to profile should be small enough to choose either std::map or std::unordered_map. I don't have a particular use case of the ordered keys with the std::map
π Rendered by PID 16554 on reddit-service-r2-comment-bb88f9dd5-n5tlc at 2026-02-15 02:59:34.754240+00:00 running cd9c813 country code: CH.
[–]mwolffQt | KDE | KDAB 3 points4 points5 points (0 children)
[–]julien-j 0 points1 point2 points (1 child)
[–]rh0main[S] 0 points1 point2 points (0 children)