Skip to content

Instantly share code, notes, and snippets.

@MattPD
MattPD / cpp.type_erasure.draft.md
Created June 17, 2021 17:28
C++ Links: Type Erasure (WIP draft)
@MattPD
MattPD / cpp.std.modules.draft.md
Last active November 8, 2023 10:30
C++ links: Modules (WIP draft)
@MattPD
MattPD / analysis.draft.md
Last active March 25, 2024 19:06
Program Analysis Resources (WIP draft)
@MattPD
MattPD / cpp.std.coroutines.draft.md
Last active March 18, 2024 19:24
C++ links: Coroutines (WIP draft)
@MattPD
MattPD / set_benchmark.cpp
Created October 8, 2016 15:54
Find Example - Benchmark (Nonius) Code
/* Running:
BNSIZE=10000; BNQUERIES=1000
./find --param=size:$BNSIZE --param=queries:$BNQUERIES >
results.size=$BNSIZE.queries=$BNQUERIES.txt
./find --param=size:$BNSIZE --param=queries:$BNQUERIES --reporter=html
--output=results.size=$BNSIZE.queries=$BNQUERIES.html
*/
Related to discussion of
http://larshagencpp.github.io/blog/2016/05/01/a-cache-miss-is-not-a-cache-miss
at https://twitter.com/gregerlars/status/726781584481878017
Three variants:
- Simple: cacheS
- Pointer: cacheP
- LinkedList: cacheL
Context -- looking at average stall durations, we can confirm that cacheL wastes considerably more instruction slots than cacheP, which wastes only somewhat more instruction slots than cacheS:
@MattPD
MattPD / main.cpp
Last active September 22, 2016 09:34
Boost.Hana: compile-time if demo
// Boost.Hana solution
// issue: http://baptiste-wicht.com/posts/2015/07/simulate-static_if-with-c11c14.html
// docs w/ explanation: http://ldionne.com/hana/#tutorial-introspection-is_valid
#include <iostream>
#include <string>
#include <boost/hana.hpp>
auto has_pop_back = boost::hana::is_valid([](auto && obj) -> decltype(obj.pop_back()) { });
#include <iostream>
using std::cout;
int main()
{
cout << "Hello! \n";
return 0;
}