Skip to content

Instantly share code, notes, and snippets.

View UplinkCoder's full-sized avatar

Stefan Koch UplinkCoder

View GitHub Profile
private enum staticMapExpandFactor = 150;
private string generateCases()
{
string[staticMapExpandFactor] chunks;
chunks[0] = q{};
static foreach (enum i; 0 .. staticMapExpandFactor - 1)
chunks[i + 1] = chunks[i] ~ `F!(Args[` ~ i.stringof ~ `]),`;
string ret = `AliasSeq!(`;
foreach (chunk; chunks)
ret ~= `q{alias staticMap = AliasSeq!(` ~ chunk ~ `);},`;
# compiler commit hash: 0e837363832a5deb0447e10f9e615c0497e521f7
# which got compiled with the following commandline:
# make -f posix.mak HOST_DMD=~/d/ldc2-1.23.0-linux-x86_64/bin/ldmd2 DFLAGS+="-g -O3"
uplimk@uplimk-virtual-machine:~/d/dmd$ hyperfine -w 10 "generated/linux/release/64/dmd xx_tf.d -sktf -c" "generated/linux/release/64/dmd xx.d -c " "generated/linux/release/64/dmd xx_adam.d -c"
Benchmark #1: generated/linux/release/64/dmd xx_tf.d -sktf -c
Time (mean ± σ): 9.1 ms ± 0.4 ms [User: 5.8 ms, System: 3.2 ms]
Range (min … max): 8.5 ms … 10.7 ms 288 runs
0.02user 0.01system 0:00.04elapsed 92%CPU (0avgtext+0avgdata 11672maxresident)k
This file has been truncated, but you can view the full file.
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
src/dmd/dimport.d(269): bytes: 136 Pool!(TypeIdentifier).makeNew()
static string skipWhiteBeforeAndAfter(const string s, out string rest)
pure nothrow @nogc @safe
{
string result = null;
size_t startAt = 0;
size_t stopAt = 0;
while(s.length > startAt)
{
@UplinkCoder
UplinkCoder / expansion_factor.sh
Created October 31, 2020 20:18
expansion_factor.sh
#!/bin/bash
orig_lines=$(cloc ${1} | tail -n 2 | head -n 1 | rev | cut -d ' ' -f 1 | rev)
time dmd -c -vcg-ast -o- ${1}
mv ${1}.cg expanded_${1}
exp_lines=$(cloc expanded_${1} | tail -n 2 | head -n 1 | rev | cut -d ' ' -f 1 | rev)
exp_factor=$(expr $exp_lines / $orig_lines)
echo ""
echo "${1} lines: $orig_lines"
echo "expanded ${1} lines: $exp_lines"
echo "-------------------------------"
bool strtoull(string input, out ulong result)
{
ptrdiff_t length = 0;
// ulong result = 0;
ptrdiff_t input_length = input.length;
char c = void;
do { c = input.ptr[length++]; }
while ((c >= '0' && c <= '9') && (input_length-- > 0));
--length;
/*******************************************************
HIDAPI - Multi-Platform library for
communication with HID devices.
Alan Ott
Signal 11 Software
8/22/2009
Copyright 2009, All Rights Reserved.
import std.stdio;
import std.algorithm;
import std.file;
import std.path;
import std.range;
import std.conv;
struct build
{
string[] include_paths;
// D's new runtime reflection preview!
import core.reflect.type;
import core.reflect.node;
import core.reflect.decl;
extern (C) void*** fnXXfn(void* p, void** pp);
static immutable fn_x = cast(immutable FunctionDeclaration) nodeFromName("fnXXfn");
pragma(msg, StructToString(cppfn_decl));
static immutable cppfn_decl = cast(immutable FunctionDeclaration) nodeFromName("cppfn");