Skip to content

Instantly share code, notes, and snippets.

View UplinkCoder's full-sized avatar

Stefan Koch UplinkCoder

View GitHub Profile
Command Mean [ms] Min [ms] Max [ms] Relative
generated/linux/release/64/dmd -run adam2.d 64 204.8 ± 22.0 193.8 280.0 1.00
generated/linux/release/64/dmd -run testCollector.d 64 289.0 ± 6.9 275.1 297.8 1.41 ± 0.16
generated/linux/release/64/dmd -run adam2.d 412 466.5 ± 42.7 440.4 586.9 2.28 ± 0.32
generated/linux/release/64/dmd -run testCollector.d 412 332.3 ± 6.7 323.3 343.2 1.62 ± 0.18
generated/linux/release/64/dmd -run adam2.d 760 771.6 ± 46.9 741.2 901.9 3.77 ± 0.47
generated/linux/release/64/dmd -run testCollector.d 760 382.3 ± 3.8 373.0 387.2 1.87 ± 0.20
generated/linux/release/64/dmd -run adam2.d 1108 1109.4 ± 25.1 1069.5 1160.2 5.42 ± 0.60
generated/linux/release/64/dmd -run testCollector.d 1108 429.2 ± 9.5 415.4 449.6 2.10 ± 0.23
-------------------------- WITHOUT CODEGEN ---------------------------------------------
uplink@uplink-GT80-2QE:~/dev/dmd$ time generated/linux/release/64/dmd testReflect.d -o-
Reflection class creation not handled for: 'this' (CtorDeclaration)
Reflection class creation not handled for: 'this' (CtorDeclaration)
Reflection class creation not handled for: '~this' (DtorDeclaration)
Reflection class creation not handled for: 'this' (CtorDeclaration)
Reflection class creation not handled for: 'this' (CtorDeclaration)
Reflection class creation not handled for: 'this' (CtorDeclaration)
Reflection class creation not handled for: 'this' (CtorDeclaration)
Couldn't handle init: 'cast(immutable(void)*)1LU' {ExpInitializer}
import std.conv : to;
import std.file;
void main(string[] args)
{
string buffer = "extern(C):\n";
buffer ~= "struct Ctx;\n\n";
int nMethods = 64;
import ctx_ = ctx;
import std.meta;
import std.traits;
template isStruct(alias S)
{
enum isStruct = (is(S == struct));
}
template isFunction(alias F)
struct TimeIt
{
ulong *ticks_var;
ulong begin;
this(ulong* var)
{
pragma(inline, true);
ticks_var = var;
begin = tsc();
}
import ctx_ = ctx;
import std.meta;
template isStruct(alias S)
{
static if (is(S == struct))
{
enum isStruct = true;
}
else
import core.reflect.reflect;
import core.reflect.transitiveVisitor;
final class Collector(CollectNodeTypes...) : TransitiveVisitor
{
static if (CollectNodeTypes.length == 1)
{
CollectNodeTypes[0][] collected_nodes;
}
else
Import = {
internalPointer: unhandled,
_scope: null,
identifier: "node_",
parent: null,
packages: [
"core",
"reflect",
]
moduleIdentifier: "node",
import core.reflect.reflect;
import core.reflect.nodeToSource;
import node_ = core.reflect.node;
auto foreachDecl(alias F)(const(Declaration)[] decls)
{
alias ResultT = typeof(F(Declaration.init));
ResultT[] result = new ResultT[](decls.length);
foreach(i, d; decls)
const(uint) fastLog10(const uint val) pure nothrow @nogc @safe
{
return (val < 10) ? 0 : (val < 100) ? 1 : (val < 1000) ? 2 : (val < 10000) ? 3
: (val < 100000) ? 4 : (val < 1000000) ? 5 : (val < 10000000) ? 6
: (val < 100000000) ? 7 : (val < 1000000000) ? 8 : 9;
}
/*@unique*/
static immutable fastPow10tbl = [
1, 10, 100, 1000, 10000, 100000, 1000000, 10000000, 100000000, 1000000000,